-
Notifications
You must be signed in to change notification settings - Fork 4
Regex Tips
The search uses Java's java.util.regex engine (similar to PCRE). Regex mode is enabled by checking the Regex checkbox.
In non-regex mode, all characters are treated as literals — just type exactly what you're looking for, including dots, parentheses, and other special characters.
| Pattern | Matches |
|---|---|
channelMap\.get |
Literal channelMap.get (dot must be escaped) |
channelMap\.(get|put) |
channelMap.get or channelMap.put
|
logger\.(info|error|warn) |
Any of the three log levels |
(?i)patient |
Case-insensitive "patient" (alternative to the checkbox) |
TODO|FIXME|HACK |
Common code markers |
2\.16\.840\.1\.113883 |
OID prefix (dots escaped) |
globalMap\.get\(['"] |
globalMap.get(' or globalMap.get("
|
new\s+Date\(\) |
new Date() with any whitespace |
throw\s+new |
Throw statements |
catch\s*\( |
Catch blocks |
var\s+\w+\s*=\s*msg |
Variables assigned from msg |
In regex mode, the following characters have special meaning and must be escaped with a backslash (\) to match literally:
. * + ? ^ $ { } [ ] ( ) | \
For example, to search for channelMap.get(, use: channelMap\.get\(
The search engine matches one line at a time. Multi-line patterns (patterns that span across line breaks) are not supported. Each line of each script is tested independently against the pattern.
This means patterns like function.*\n.*return will not work. Instead, search for a distinctive part of what you're looking for on a single line.
The search engine enforces a per-script timeout of 5 seconds for regex matching. If a regex takes too long on a particular script (typically due to catastrophic backtracking), the search will stop on that script and report a timeout in the results.
To avoid slow patterns:
- Prefer literal search (regex off) when you don't need pattern matching
- Avoid nested quantifiers like
(a+)+or(a*)* - Avoid excessive alternation with overlapping patterns
- Keep patterns as specific as possible
If you enter an invalid regular expression, the search will display an error message describing the problem rather than failing silently. The error message comes from Java's regex compiler and identifies the issue and position in the pattern.
OIE Source Code Search