/** * @name String instead of regular expression * @description Calling 'String.prototype.replace' or 'String.prototype.split' with a string argument that looks like a regular expression is probably a mistake because the called function will not convert the string into a regular expression. * @kind problem * @problem.severity warning * @id js/string-instead-of-regex * @tags correctness * @precision high */ import javascript /** * Gets a regular expression pattern that matches the syntax of likely regular expressions. */ private string getALikelyRegExpPattern() { result = [ "/.*/[gimuy]{1,5}", // pattern with at least one flag: /foo/i "/\\^.*/[gimuy]{0,5}", // pattern with anchor: /^foo/ "/.*\\$/[gimuy]{0,5}", // pattern with anchor: /foo$/ "\\^.*\\$", // pattern body with anchors: ^foo$ ".*(?