SERVICENOW
REGEX TESTER.
Build and test regular expressions for ServiceNow client scripts, business rules, inbound email actions, and ACL conditions. Pick a preset, tweak the pattern, and copy a ready-to-paste snippet.
Presets
Linked record 6816f79cc0a8016401c5a33be04be441 and parent a9e30c7d4ff1120031577d2ca310c7f3 — see logs.
2 matches
Match details
| # | Pos | Value | Groups |
|---|---|---|---|
| 0 | 14 | 6816f79cc0a8016401c5a33be04be441 | — |
| 1 | 58 | a9e30c7d4ff1120031577d2ca310c7f3 | — |
Copy into ServiceNow
// Business Rule (before / after)
(function executeRule(current, previous) {
var re = /\b[a-f0-9]{32}\b/gi;
var text = current.short_description.toString();
var hits = text.match(re) || [];
gs.info('regex hits: ' + hits.length + ' → ' + hits.join(', '));
})(current, previous);Regex gotchas in ServiceNow
- Server scripts run on a Rhino-derived engine. Lookbehind
(?<=)is unreliable on older instances — prefer capture groups. - In XML condition strings (sys_dictionary defaults, UI Policy expressions), escape backslashes twice —
\\din JS becomes\\\\din XML. GlideElement.toString()before.match()on server side or you may getundefinedon empty fields.- In inbound email actions, combine
email.subject+email.body_textbefore matching so values in either place are caught.