1 comment

[ 3.1 ms ] story [ 12.7 ms ] thread
var search_term_is_found = base_text.match( new RegExp("(?=(.|[\r\n])" + search_term .match(/"([^"]+)"|[\w]+/gi) .join(")((.|[\?=r\n])") .replace(/\"/g,'')+")(.|[\r\n])+", "ig") )!=null

Built Using RegEx Negative Lookaheads

bar(?=bar) finds the 1st bar (“bar” which has “bar” after it)