Invalid regular expression error in javascript
If '[' special character is used in regex constructor object, it throws Invalid regular expression: /mat[/: Unterminated character class function findMatch() { var string="Find the match"; var text = "Mat["; string.replace(new RegExp(text, 'gi'), "found") } Why this error is occuring…