Alex Gulakov's Blog - JavaScript function to search like in Google (medium.com) 2 points by xfreestar 3y ago ↗ HN
[–] xfreestar 3y ago ↗ 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") )!=nullBuilt Using RegEx Negative Lookaheadsbar(?=bar) finds the 1st bar (“bar” which has “bar” after it)
1 comment
[ 3.1 ms ] story [ 12.7 ms ] threadBuilt Using RegEx Negative Lookaheads
bar(?=bar) finds the 1st bar (“bar” which has “bar” after it)