<tbody>
<row>
<entry> <literal>\d</literal> </entry>
- <entry> <literal>[[:digit:]]</literal> </entry>
+ <entry> matches any digit, like
+ <literal>[[:digit:]]</literal> </entry>
</row>
<row>
<entry> <literal>\s</literal> </entry>
- <entry> <literal>[[:space:]]</literal> </entry>
+ <entry> matches any whitespace character, like
+ <literal>[[:space:]]</literal> </entry>
</row>
<row>
<entry> <literal>\w</literal> </entry>
- <entry> <literal>[[:word:]]</literal> </entry>
+ <entry> matches any word character, like
+ <literal>[[:word:]]</literal> </entry>
</row>
<row>
<entry> <literal>\D</literal> </entry>
- <entry> <literal>[^[:digit:]]</literal> </entry>
+ <entry> matches any non-digit, like
+ <literal>[^[:digit:]]</literal> </entry>
</row>
<row>
<entry> <literal>\S</literal> </entry>
- <entry> <literal>[^[:space:]]</literal> </entry>
+ <entry> matches any non-whitespace character, like
+ <literal>[^[:space:]]</literal> </entry>
</row>
<row>
<entry> <literal>\W</literal> </entry>
- <entry> <literal>[^[:word:]]</literal> </entry>
+ <entry> matches any non-word character, like
+ <literal>[^[:word:]]</literal> </entry>
</row>
</tbody>
</tgroup>
If newline-sensitive matching is specified, <literal>.</literal>
and bracket expressions using <literal>^</literal>
will never match the newline character
- (so that matches will never cross newlines unless the RE
- explicitly arranges it)
+ (so that matches will not cross lines unless the RE
+ explicitly includes a newline)
and <literal>^</literal> and <literal>$</literal>
will match the empty string after and before a newline
respectively, in addition to matching at beginning and end of string
respectively.
But the ARE escapes <literal>\A</literal> and <literal>\Z</literal>
continue to match beginning or end of string <emphasis>only</emphasis>.
+ Also, the character class shorthands <literal>\D</literal>
+ and <literal>\W</literal> will match a newline regardless of this mode.
+ (Before <productname>PostgreSQL</productname> 14, they did not match
+ newlines when in newline-sensitive mode.
+ Write <literal>[^[:digit:]]</literal>
+ or <literal>[^[:word:]]</literal> to get the old behavior.)
</para>
<para>
/* build arcs for char class; this may cause color splitting */
subcolorcvec(v, cv, cstate, cstate);
-
- /* in NLSTOP mode, ensure newline is not part of the result set */
- if (v->cflags & REG_NLSTOP)
- newarc(v->nfa, PLAIN, v->nlcolor, cstate, cstate);
NOERR();
/* clean up any subcolors in the arc set */
NOERR();
bracket(v, left, right);
+
+ /* in NLSTOP mode, ensure newline is not part of the result set */
if (v->cflags & REG_NLSTOP)
newarc(v->nfa, PLAIN, v->nlcolor, left, right);
NOERR();
test_regex
-------------------------------
{0,REG_UNONPOSIX,REG_ULOCALE}
- {abc}
+ {"abc +
+ def"}
(2 rows)
select * from test_regex('[\D]+', E'abc\ndef345', 'LPE');
test_regex
----------------------------------------
{0,REG_UBBS,REG_UNONPOSIX,REG_ULOCALE}
- {abc}
+ {"abc +
+ def"}
(2 rows)
select * from test_regex('\w+', E'abc_012\ndef', 'LP');
test_regex
-------------------------------
{0,REG_UNONPOSIX,REG_ULOCALE}
- {***}
+ {"*** +
+ @@@"}
(2 rows)
select * from test_regex('[\W]+', E'***\n@@@___', 'LPE');
test_regex
----------------------------------------
{0,REG_UBBS,REG_UNONPOSIX,REG_ULOCALE}
- {***}
+ {"*** +
+ @@@"}
(2 rows)
-- doing 13 "escapes"