Javascript regex for multiliners for new Regexp

var urlRegExp = new RegExp("/----(-| )BEGIN.[^-]----(-| )END.*(-| )----/","im");

I have this regex to match text like below:

-----BEGIN CERTIFICATE-----
MIICyjCCAjOgAwIBAgIJAKyp8/Dgbww+MA0GCSqGSIb3DQEBCwUAMH4xCzAJBgNV
BAYTAkRFMQswCQYDVQQIDAJCVzELMAkGA1UEBwwCS0ExDzANBgNVBAoMBkFzdGFy
bzEOMAwGA1UECwwFUmF2ZWwxEzARBgNVBAMMCjEwLjguMzAuNzYxHzAdBgkqhkiG
9w0BCQEWEGhodW5kQGFzdGFyby5jb20wHhcNMTUwMzA1MTIxODI2WhcNMjUwMzAy
MTIxODI2WjB+MQswCQYDVQQGEwJERTELMAkGA1UECAwCQlcxCzAJBgNVBAcMAktB
MQ8wDQYDVQQKDAZBc3Rhcm8xDjAMBgNVBAsMBVJhdmVsMRMwEQYDVQQDDAoxMC44
LjMwLjc2MR8wHQYJKoZIhvcNAQkBFhBoaHVuZEBhc3Rhcm8uY29tMIGfMA0GCSqG
SIb3DQEBAQUAA4GNADCBiQKBgQC5b/oNa3Q4PmHY6BDtnPuJyRWfFLVPPtLA6SnG
owlZDTikqdhwFav8VvGDaCG2xNKQKbgVpuqaMesfY4qqs74WBBAXUW+PKzvBibRZ
UxR9EVBe1tvXK82LQHp9r37tZGgFqhvVJRwE3RLvyXrsjIBT7mKG/EUIj5zp1t9Y
erjHtwIDAQABo1AwTjAdBgNVHQ4EFgQUuIyeidlmNK5hOCCrqgel9SZQWhwwHwYD
VR0jBBgwFoAUuIyeidlmNK5hOCCrqgel9SZQWhwwDAYDVR0TBAUwAwEB/zANBgkq
hkiG9w0BAQsFAAOBgQBO00eY+EjcudWUoMRLHiWjY96xcBP/WGdZa/LvZFaW/7uM
AH3fkKTYJYAMPi8UOA8GpI1mkPztQfISTJ1a8KwOcoKtO48oC8SrmFa/V1aObh/Z
rPWw1s5/e1rAlEH4nCt6n8C/R+Lw/O8klnzlsSG6vnUBxJAWsvubK/8SYg4aOQ== 
-----END CERTIFICATE-----

but it is not working. Can anybody help?


Source: regex

Leave a Reply