Javascript RegExp Instance Methods toString()

Introduction

Javascript RegExp methods toLocaleString() and toString() return the literal representation of the regular expression, regardless of how it was created.

Consider this example:

let pattern = new RegExp("\\[bc\\]at", "gi");
console.log(pattern.toString()); // /\[bc\]at/gi 
console.log(pattern.toLocaleString()); // /\[bc\]at/gi 



PreviousNext

Related