Skip to content

Commit

Permalink
Example search engine: Match all words, in any order (#26971)
Browse files Browse the repository at this point in the history
* match all words, in any order

* docs: match all words, in any order
  • Loading branch information
sunag committed Oct 16, 2023
1 parent 982153e commit f14779f
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
4 changes: 3 additions & 1 deletion docs/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -359,7 +359,9 @@ <h1><a href="https://threejs.org">three.js</a></h1>

function escapeRegExp( string ) {

return string.replace( /[.*+?^${}()|[\]\\]/g, '\\$&' ); // https://stackoverflow.com/a/6969486/5250847
string = string.replace( /[.*+?^${}()|[\]\\]/g, '\\$&' ); // https://stackoverflow.com/a/6969486/5250847

return '(?=.*' + string.split( ' ' ).join( ')(?=.*' ) + ')'; // match all words, in any order

}

Expand Down
4 changes: 3 additions & 1 deletion examples/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -253,7 +253,9 @@ <h1><a href="https://threejs.org">three.js</a></h1>

function escapeRegExp( string ) {

return string.replace( /[.*+?^${}()|[\]\\]/g, '\\$&' ); // https://stackoverflow.com/a/6969486/5250847
string = string.replace( /[.*+?^${}()|[\]\\]/g, '\\$&' ); // https://stackoverflow.com/a/6969486/5250847

return '(?=.*' + string.split( ' ' ).join( ')(?=.*' ) + ')'; // match all words, in any order

}

Expand Down

0 comments on commit f14779f

Please sign in to comment.