219 |
If any call to \fBpcre_exec()\fP in a \fB/g\fP or \fB/G\fP sequence matches an |
If any call to \fBpcre_exec()\fP in a \fB/g\fP or \fB/G\fP sequence matches an |
220 |
empty string, the next call is done with the PCRE_NOTEMPTY_ATSTART and |
empty string, the next call is done with the PCRE_NOTEMPTY_ATSTART and |
221 |
PCRE_ANCHORED flags set in order to search for another, non-empty, match at the |
PCRE_ANCHORED flags set in order to search for another, non-empty, match at the |
222 |
same point. If this second match fails, the start offset is advanced by one |
same point. If this second match fails, the start offset is advanced, and the |
223 |
character, and the normal match is retried. This imitates the way Perl handles |
normal match is retried. This imitates the way Perl handles such cases when |
224 |
such cases when using the \fB/g\fP modifier or the \fBsplit()\fP function. |
using the \fB/g\fP modifier or the \fBsplit()\fP function. Normally, the start |
225 |
|
offset is advanced by one character, but if the newline convention recognizes |
226 |
|
CRLF as a newline, and the current character is CR followed by LF, an advance |
227 |
|
of two is used. |
228 |
. |
. |
229 |
. |
. |
230 |
.SS "Other modifiers" |
.SS "Other modifiers" |
279 |
For this reason, it must be the last modifier. The given locale is set, |
For this reason, it must be the last modifier. The given locale is set, |
280 |
\fBpcre_maketables()\fP is called to build a set of character tables for the |
\fBpcre_maketables()\fP is called to build a set of character tables for the |
281 |
locale, and this is then passed to \fBpcre_compile()\fP when compiling the |
locale, and this is then passed to \fBpcre_compile()\fP when compiling the |
282 |
regular expression. Without an \fB/L\fP modifier, NULL is passed as the tables |
regular expression. Without an \fB/L\fP (or \fB/T\fP) modifier, NULL is passed |
283 |
pointer; that is, \fB/L\fP applies only to the expression on which it appears. |
as the tables pointer; that is, \fB/L\fP applies only to the expression on |
284 |
|
which it appears. |
285 |
.P |
.P |
286 |
The \fB/M\fP modifier causes the size of memory block used to hold the compiled |
The \fB/M\fP modifier causes the size of memory block used to hold the compiled |
287 |
pattern to be output. |
pattern to be output. |
289 |
The \fB/S\fP modifier causes \fBpcre_study()\fP to be called after the |
The \fB/S\fP modifier causes \fBpcre_study()\fP to be called after the |
290 |
expression has been compiled, and the results used when the expression is |
expression has been compiled, and the results used when the expression is |
291 |
matched. |
matched. |
292 |
|
.P |
293 |
|
The \fB/T\fP modifier must be followed by a single digit. It causes a specific |
294 |
|
set of built-in character tables to be passed to \fBpcre_compile()\fP. It is |
295 |
|
used in the standard PCRE tests to check behaviour with different character |
296 |
|
tables. The digit specifies the tables as follows: |
297 |
|
.sp |
298 |
|
0 the default ASCII tables, as distributed in |
299 |
|
pcre_chartables.c.dist |
300 |
|
1 a set of tables defining ISO 8859 characters |
301 |
|
.sp |
302 |
|
In table 1, some characters whose codes are greater than 128 are identified as |
303 |
|
letters, digits, spaces, etc. |
304 |
. |
. |
305 |
. |
. |
306 |
.SS "Using the POSIX wrapper API" |
.SS "Using the POSIX wrapper API" |
414 |
.\" JOIN |
.\" JOIN |
415 |
\e? pass the PCRE_NO_UTF8_CHECK option to |
\e? pass the PCRE_NO_UTF8_CHECK option to |
416 |
\fBpcre_exec()\fP or \fBpcre_dfa_exec()\fP |
\fBpcre_exec()\fP or \fBpcre_dfa_exec()\fP |
|
\e>dd start the match at offset dd (any number of digits); |
|
417 |
.\" JOIN |
.\" JOIN |
418 |
this sets the \fIstartoffset\fP argument for \fBpcre_exec()\fP |
\e>dd start the match at offset dd (optional "-"; then |
419 |
or \fBpcre_dfa_exec()\fP |
any number of digits); this sets the \fIstartoffset\fP |
420 |
|
argument for \fBpcre_exec()\fP or \fBpcre_dfa_exec()\fP |
421 |
.\" JOIN |
.\" JOIN |
422 |
\e<cr> pass the PCRE_NEWLINE_CR option to \fBpcre_exec()\fP |
\e<cr> pass the PCRE_NEWLINE_CR option to \fBpcre_exec()\fP |
423 |
or \fBpcre_dfa_exec()\fP |
or \fBpcre_dfa_exec()\fP |
502 |
\fBpcre_exec()\fP returns, starting with number 0 for the string that matched |
\fBpcre_exec()\fP returns, starting with number 0 for the string that matched |
503 |
the whole pattern. Otherwise, it outputs "No match" when the return is |
the whole pattern. Otherwise, it outputs "No match" when the return is |
504 |
PCRE_ERROR_NOMATCH, and "Partial match:" followed by the partially matching |
PCRE_ERROR_NOMATCH, and "Partial match:" followed by the partially matching |
505 |
substring when \fBpcre_exec()\fP returns PCRE_ERROR_PARTIAL. For any other |
substring when \fBpcre_exec()\fP returns PCRE_ERROR_PARTIAL. (Note that this is |
506 |
returns, it outputs the PCRE negative error number. Here is an example of an |
the entire substring that was inspected during the partial match; it may |
507 |
interactive \fBpcretest\fP run. |
include characters before the actual match start if a lookbehind assertion, |
508 |
|
\eK, \eb, or \eB was involved.) For any other returns, it outputs the PCRE |
509 |
|
negative error number. Here is an example of an interactive \fBpcretest\fP run. |
510 |
.sp |
.sp |
511 |
$ pcretest |
$ pcretest |
512 |
PCRE version 7.0 30-Nov-2006 |
PCRE version 7.0 30-Nov-2006 |
589 |
(Using the normal matching function on this data finds only "tang".) The |
(Using the normal matching function on this data finds only "tang".) The |
590 |
longest matching string is always given first (and numbered zero). After a |
longest matching string is always given first (and numbered zero). After a |
591 |
PCRE_ERROR_PARTIAL return, the output is "Partial match:", followed by the |
PCRE_ERROR_PARTIAL return, the output is "Partial match:", followed by the |
592 |
partially matching substring. |
partially matching substring. (Note that this is the entire substring that was |
593 |
|
inspected during the partial match; it may include characters before the actual |
594 |
|
match start if a lookbehind assertion, \eK, \eb, or \eB was involved.) |
595 |
.P |
.P |
596 |
If \fB/g\fP is present on the pattern, the search for further matches resumes |
If \fB/g\fP is present on the pattern, the search for further matches resumes |
597 |
at the end of the longest match. For example: |
at the end of the longest match. For example: |
770 |
.rs |
.rs |
771 |
.sp |
.sp |
772 |
.nf |
.nf |
773 |
Last updated: 16 May 2010 |
Last updated: 06 November 2010 |
774 |
Copyright (c) 1997-2010 University of Cambridge. |
Copyright (c) 1997-2010 University of Cambridge. |
775 |
.fi |
.fi |