[Edit]
+
0
-
0
js escape regex pattern characters
1 2 3 4 5const expression = new RegExp('\\.\\*', 'g'); // where: \\ will be converted to \ in the string literal // . escaped by \. and * escaped by \* // Topic: https://dirask.com/questions/JavaScript-why-in-string-value-should-I-use-to-get-and-in-read-file-only-double-backslashes-in-strings-1b6xJ1 console.log(expression.source); // '\\.\\*' <---- source returns string literals with changed \ to \\