/** * @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}" or // pattern with at least one flag: /foo/i result = "/\\^.*/[gimuy]{0,5}" or // pattern with anchor: /^foo/ result = "/.*\\$/[gimuy]{0,5}" or // pattern with anchor: /foo$/ result = "\\^.*\\$" or // pattern body with anchors: ^foo$ result = ".*(?