Documentation update regarding \Q handling.

This commit is contained in:
Philip.Hazel 2018-07-28 15:08:22 +00:00
parent a9453f096f
commit 27337495dc
2 changed files with 28 additions and 17 deletions

View File

@ -1,4 +1,4 @@
.TH PCRE2COMPAT 3 "27 July 2018" "PCRE2 10.32"
.TH PCRE2COMPAT 3 "28 July 2018" "PCRE2 10.32"
.SH NAME
PCRE2 - Perl-compatible regular expressions (revised API)
.SH "DIFFERENCES BETWEEN PCRE2 AND PERL"
@ -29,12 +29,13 @@ assertion is a condition that has a matching branch (that is, the condition is
false).
.P
4. The following Perl escape sequences are not supported: \eF, \el, \eL, \eu,
\eU, and \eN when followed by a character name. (\eN on its own, matching a
non-newline character, is supported.) The escapes that modify the case of
following letters are implemented by Perl's general string-handling and are not
part of its pattern matching engine. If any of these are encountered by PCRE2,
an error is generated by default. However, if the PCRE2_ALT_BSUX option is set,
\eU and \eu are interpreted as ECMAScript interprets them.
\eU, and \eN when followed by a character name. \eN on its own, matching a
non-newline character, and \eN{U+dd..}, matching a Unicode code point, are
supported. The escapes that modify the case of following letters are
implemented by Perl's general string-handling and are not part of its pattern
matching engine. If any of these are encountered by PCRE2, an error is
generated by default. However, if the PCRE2_ALT_BSUX option is set, \eU and \eu
are interpreted as ECMAScript interprets them.
.P
5. The Perl escape sequences \ep, \eP, and \eX are supported only if PCRE2 is
built with Unicode support (the default). The properties that can be tested
@ -45,19 +46,24 @@ documentation says "Because Perl hides the need for the user to understand the
internal representation of Unicode characters, there is no need to implement
the somewhat messy concept of surrogates."
.P
6. PCRE2 does support the \eQ...\eE escape for quoting substrings. Characters
in between are treated as literals. This is slightly different from Perl in
that $ and @ are also handled as literals inside the quotes. In Perl, they
cause variable interpolation (but of course PCRE2 does not have variables).
Note the following examples:
6. PCRE2 supports the \eQ...\eE escape for quoting substrings. Characters
in between are treated as literals. However, this is slightly different from
Perl in that $ and @ are also handled as literals inside the quotes. In Perl,
they cause variable interpolation (but of course PCRE2 does not have
variables). Also, Perl does "double-quotish backslash interpolation" on any
backslashes between \eQ and \eE which, its documentation says, "may lead to
confusing results". PCRE2 treats a backslash between \eQ and \eE just like any
other character. Note the following examples:
.sp
Pattern PCRE2 matches Perl matches
Pattern PCRE2 matches Perl matches
.sp
.\" JOIN
\eQabc$xyz\eE abc$xyz abc followed by the
contents of $xyz
\eQabc\e$xyz\eE abc\e$xyz abc\e$xyz
\eQabc\eE\e$\eQxyz\eE abc$xyz abc$xyz
\eQA\eB\eE A\eB A\eB
\eQ\e\eE \e \e\eE
.sp
The \eQ...\eE sequence is recognized both inside and outside character classes.
.P
@ -194,6 +200,6 @@ Cambridge, England.
.rs
.sp
.nf
Last updated: 27 July 2018
Last updated: 28 July 2018
Copyright (c) 1997-2018 University of Cambridge.
.fi

View File

@ -1,4 +1,4 @@
.TH PCRE2PATTERN 3 "27 July 2018" "PCRE2 10.32"
.TH PCRE2PATTERN 3 "28 July 2018" "PCRE2 10.32"
.SH NAME
PCRE2 - Perl-compatible regular expressions (revised API)
.SH "PCRE2 REGULAR EXPRESSION DETAILS"
@ -331,7 +331,10 @@ of the pattern.
If you want to remove the special meaning from a sequence of characters, you
can do so by putting them between \eQ and \eE. This is different from Perl in
that $ and @ are handled as literals in \eQ...\eE sequences in PCRE2, whereas
in Perl, $ and @ cause variable interpolation. Note the following examples:
in Perl, $ and @ cause variable interpolation. Also, Perl does "double-quotish
backslash interpolation" on any backslashes between \eQ and \eE which, its
documentation says, "may lead to confusing results". PCRE2 treats a backslash
between \eQ and \eE just like any other character. Note the following examples:
.sp
Pattern PCRE2 matches Perl matches
.sp
@ -340,6 +343,8 @@ in Perl, $ and @ cause variable interpolation. Note the following examples:
contents of $xyz
\eQabc\e$xyz\eE abc\e$xyz abc\e$xyz
\eQabc\eE\e$\eQxyz\eE abc$xyz abc$xyz
\eQA\eB\eE A\eB A\eB
\eQ\e\eE \e \e\eE
.sp
The \eQ...\eE sequence is recognized both inside and outside character classes.
An isolated \eE that is not preceded by \eQ is ignored. If \eQ is not followed
@ -3604,6 +3609,6 @@ Cambridge, England.
.rs
.sp
.nf
Last updated: 27 July 2018
Last updated: 28 July 2018
Copyright (c) 1997-2018 University of Cambridge.
.fi