(*UCP), (*UTF), (*CRLF) — PCRE2's options at the start of the pattern¶
One line: PCRE2 lets a pattern begin with (*…) items that set options the caller would otherwise have to pass in code — (*UTF) to treat the subject as UTF-8, (*UCP) to make \w, \d and \b Unicode-aware, (*CRLF) to make $ and . understand Windows line endings, (*LIMIT_MATCH=n) to cap the backtracking — and because ABAP's PCRE addition is PCRE2, these are the options an ABAP pattern can carry inside itself.
Level: reference · PCRE2 only, measured with pcre2grep
What it means¶
None of the eight engines the probe drives has this syntax, and the table below says so in every cell. That is the honest answer for those engines, and it is not the interesting one. These options exist because a pattern often travels without its options — into a config file, a database column, a FIND … PCRE statement — and PCRE2 lets the pattern say what it needs.
| Option | Sets | The caller's equivalent |
|---|---|---|
(*UTF) |
subject and pattern are UTF-8; . is a character, not a byte |
PCRE2_UTF |
(*UCP) |
\w, \d, \s, \b, POSIX classes use Unicode properties |
PCRE2_UCP |
(*CRLF), (*LF), (*CR), (*ANYCRLF), (*ANY) |
what counts as a newline for ^, $, ., \N |
PCRE2_NEWLINE_* |
(*LIMIT_MATCH=n), (*LIMIT_DEPTH=n), (*LIMIT_HEAP=n) |
resource limits for the match | the match context |
(*NO_AUTO_POSSESS), (*NO_START_OPT), (*NO_JIT) |
turn optimisations off | compile/JIT options |
(*CASELESS_RESTRICT), (*TURKISH_CASING) |
case-folding rules, 10.43+ / 10.45+ | see case-insensitive matching |
They must come first, before anything else in the pattern, and several may be stacked: (*UTF)(*UCP)^\w+$.
Measured, in the eight engines¶
Verified output of kw_start_of_pattern_options_sh.sh — regenerated by tools/run_examples.py, never hand-typed.
construct python perl node ruby java go rust fancy
(*UCP) - - - - - - - -
(*UTF) - - - - - - - -
(*CRLF) - - - - - - - -
(*LIMIT_MATCH=10) - - - - - - - -
Every cell is -. No other engine has the syntax, and none of them accepts it as something else — a clean refusal everywhere, which is rarer on this shelf than it should be.
Measured, in PCRE2¶
Real run — PCRE2 10.48 (pcre2grep), macOS 26.6.2 x86-64, 2026-09-22. e_acute.txt holds U+00E9 as its two UTF-8 bytes; crlf.txt holds a and b on lines ending in CR LF; thirty.txt holds thirty as and a !. -c counts matching lines; the exit status is 0 for a match and 1 for none.
$ pcre2grep --utf --no-ucp -c '^\w$' e_acute.txt
0
$ pcre2grep --utf --no-ucp -c '(*UCP)^\w$' e_acute.txt
1
$ pcre2grep -c '^.$' e_acute.txt
0
$ pcre2grep -c '(*UTF)^.$' e_acute.txt
1
$ pcre2grep -M -N LF -c 'a$' crlf.txt
0
$ pcre2grep -M -N LF -c '(*CRLF)a$' crlf.txt
1
$ pcre2grep -c '^(a+)+$' thirty.txt
pcre2grep: pcre2_match() gave error -47 while matching this text:
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa!
pcre2grep: Error -46, -47, -53 or -63 means that a resource limit was exceeded.
pcre2grep: Check your regex for nested unlimited loops.
0
$ pcre2grep -c '(*LIMIT_MATCH=1000)^(?>a+)+$' thirty.txt
0
Three things to read off that:
(*UCP)is what makes\wmatché. With UTF mode on and UCP off —--utf --no-ucp, the library's own default —^\w$does not match one accented letter; with(*UCP)in the pattern it does.pcre2grep -uturns both on for you, which is convenient and hides the distinction; ABAP does not, and an ABAP pattern that wants Unicode\whas to say(*UCP). The\wlesson measures the same thing from the other side.(*UTF)is what makes.one character. Without it, PCRE2 sees two bytes and^.$fails.(*CRLF)is what makes$see a Windows line ending. With the newline convention forced to LF,a$cannot matcha\r\n;(*CRLF)in the pattern overrides the caller's convention.
The last two commands are the catastrophic backtracking story: PCRE2's default match limit stops ^(a+)+$ on thirty characters with error −47, and the atomic version ^(?>a+)+$ answers cleanly (no match, because of the !). A (*LIMIT_MATCH=10) on a four-character subject that matches by default did not produce the error in this run, in either direction; the interaction between an in-pattern limit and pcre2grep's own limit handling was not investigated further, and this page makes no claim about it.
For ABAP¶
FIND PCRE '(*UCP)\w+' IN lv_text is legal ABAP, and it is the way to ask for Unicode word characters without a class of \p{L} and friends. Nothing here ran on an ABAP system; the claim is that PCRE2 is the library in the kernel, and the transcript above is that library.
See also¶
- Inline flags — the
(?…)options, which every engine has some of; these(*…)options are the ones only PCRE2 has. - Backtracking verbs — the other
(*…)syntax, which appears mid-pattern and does something entirely different. pcre2pattern↗ — the reference list of start-of-pattern items.- Unicode text · Multiline text and logs.