Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Regex - Extract a substring of a email document with a regular expression

I'm trying to extract a substring of an email document with a regular expression. I'm testing the regex online, and it works perfectly:

online regex tester

I have a function to check the regex on Google Apps Script and the same regex isn't working here.

var regex = new RegExp("Intrusion signature\(s\)\:\n\n(.*)");
var e = regex.exec(data);

Google Apps Script code

Logger

Does anyone knows why is not working?

like image 496
Juan Bravo Roig Avatar asked Dec 11 '22 07:12

Juan Bravo Roig


1 Answers

Using a literal regex instead of converting the string to a regex works.

var regex = new RegExp(/Intrusion signature\(s\)\:\n\n(.*)/);

enter image description here

like image 114
James D Avatar answered Dec 28 '22 05:12

James D