I have this JavaScript code:
var textareas = document.getElementsByTagName('textarea');
var content = textareas[0].value;
var reg = new RegExp(/^.*[[]#.+#[]].*$/mgi);
var res = content.match(reg); // always null
The content var contains a long multiline string that contains patterns like [#some text goes here#]
. I tested the regex with some online testing tools and it works against the string. Using the regex in JavaScript fails though - any idea why?
Thanks!
^
and$
along with them
modifier. So does this mean that you only want to match when the[#some text goes here#]
is the only thing on the line? – squint Feb 7 '12 at 15:47