JavaScript and RegEx

regular expressions + string variable + javascript


var body = "this is a \n blob of text that could be an article or whatever.";

var search_string = "Blob of text";

var re = new RegExp(search_string, "gim");

var output = body.match(re);

console.log(output);

if ( body.match(re) ) {
    console.log("match");
} else {
    console.log("no match");
}

From JR's : articles
53 words - 350 chars
created on - #
source - versions



A     A     A     A     A

© 2013-2017 JotHut - Online notebook

current date: Mar 12, 2025 - 12:23 p.m. EDT