Several functions in ZWL accepts a regex pattern. ZWL has a few rules for a valid regex pattern:
The pattern must be a
stringwith no forward slashes (
Named groups are written with syntax
Regex flags in ZWL can be given using syntax
(?idmsuxU)PATTERN_STARTS_FROM_HERE. See following example:
assertTrue(find(`That Clever animalis a FOX`, '(?i)clever[\\s\\S]*fox'))
\are used to escape characters in a
string, if a pattern contains
\, escape it using another backslash like so
If you're writing complex regex patterns, we suggest testing them using a tool like regexr for better clarity and debugging.
If you need help in writing regular expressions, mdn is a great source to start with.