Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

convert string to regular expression js

// Let's say you do str.matchAll(char) but char is ) or @, etc. This will throw an error.
// That's is why, before matchAll, we must escape the string like that:
str = str.replace(/[|{}()[]^$+*?.]/g, '$&')
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #convert #string #regular #expression #js
ADD COMMENT
Topic
Name
7+2 =