Last active
August 24, 2021 09:48
-
-
Save LukyVj/a632803b7ba6268e51edcfa347a09ac2 to your computer and use it in GitHub Desktop.
Nothing to see here officer
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function getQueryPattern(query, flags = "i") { | |
const pattern = new RegExp( | |
`(${query | |
.trim() // Trim leading and ending whitespace | |
.toLowerCase() // convert to lower case | |
.split(" ") // Split on spaces for multiple commands | |
.map((token) => `^${token}`) // Map over the resulting array and create Regex_ | |
.join("|")})`, // Join those expressions with an OR | | |
flags | |
);\n | |
return pattern; | |
} | |
\n | |
export default function App() { /* ... */ } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment