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?
Using a literal regex instead of converting the string to a regex works.
var regex = new RegExp(/Intrusion signature\(s\)\:\n\n(.*)/);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With