use more set literals instead of big disjunctions

This commit is contained in:
Erik Krogh Kristensen
2022-05-24 11:09:10 +02:00
parent b48806968c
commit a404a8c61a
4 changed files with 67 additions and 62 deletions

View File

@@ -14,13 +14,16 @@ 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 = ".*(?<!\\\\)\\\\[dDwWsSB].*" or // contains a builtin character class: \s
result = ".*(?<!\\\\)\\\\[\\[\\]()*+?{}|^$.].*" or // contains an escaped meta-character: \(
result = ".*\\[\\^?[\\p{Alnum}\\p{Blank}_-]+\\][*+].*" // contains a quantified custom character class: [^a-zA-Z123]+
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$
".*(?<!\\\\)\\\\[dDwWsSB].*", // contains a builtin character class: \s
".*(?<!\\\\)\\\\[\\[\\]()*+?{}|^$.].*", // contains an escaped meta-character: \(
".*\\[\\^?[\\p{Alnum}\\p{Blank}_-]+\\][*+].*" // contains a quantified custom character class: [^a-zA-Z123]+
]
}
/**