// 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, '$&')