I need to build a regular expression where the expression contents are variable.
for example I have a string that i need to search for, but the string can change. If i have a variable called string I need to look at the contents of string otherwise
Martin John Brindle wrote:> I need to build a regular expression where the expression contents are > variable.>
for example I have a string that i need to search for, but the string can > change. If i have a variable called string I need to look at the contents of > string otherwise>
/string/>
obviously doesn't work!>
Suggestions appreciated.
function searchFor( s, str ) { var re = new RegExp( s ); return re.test( str ); }
If you would like to report an abuse of our service, such as a spam message, please . Если Вы хотите пожаловаться на содержимое этой страницы, пожалуйста .