71 |
.P |
.P |
72 |
If PCRE_PARTIAL is set for a pattern that does not conform to the restrictions, |
If PCRE_PARTIAL is set for a pattern that does not conform to the restrictions, |
73 |
\fBpcre_exec()\fP returns the error code PCRE_ERROR_BADPARTIAL (-13). |
\fBpcre_exec()\fP returns the error code PCRE_ERROR_BADPARTIAL (-13). |
74 |
|
You can use the PCRE_INFO_OKPARTIAL call to \fBpcre_fullinfo()\fP to find out |
75 |
|
if a compiled pattern can be used for partial matching. |
76 |
. |
. |
77 |
. |
. |
78 |
.SH "EXAMPLE OF PARTIAL MATCHING USING PCRETEST" |
.SH "EXAMPLE OF PARTIAL MATCHING USING PCRETEST" |
101 |
\fBpcre_dfa_exec()\fP matching (by means of the \eD escape sequence), produces |
\fBpcre_dfa_exec()\fP matching (by means of the \eD escape sequence), produces |
102 |
the following output: |
the following output: |
103 |
.sp |
.sp |
104 |
re> /^\d?\d(jan|feb|mar|apr|may|jun|jul|aug|sep|oct|nov|dec)\d\d$/ |
re> /^\ed?\ed(jan|feb|mar|apr|may|jun|jul|aug|sep|oct|nov|dec)\ed\ed$/ |
105 |
data> 25jun04\eP\eD |
data> 25jun04\eP\eD |
106 |
0: 25jun04 |
0: 25jun04 |
107 |
data> 23dec3\eP\eD |
data> 23dec3\eP\eD |
128 |
are stored. Here is an example using \fBpcretest\fP, using the \eR escape |
are stored. Here is an example using \fBpcretest\fP, using the \eR escape |
129 |
sequence to set the PCRE_DFA_RESTART option (\eP and \eD are as above): |
sequence to set the PCRE_DFA_RESTART option (\eP and \eD are as above): |
130 |
.sp |
.sp |
131 |
re> /^\d?\d(jan|feb|mar|apr|may|jun|jul|aug|sep|oct|nov|dec)\d\d$/ |
re> /^\ed?\ed(jan|feb|mar|apr|may|jun|jul|aug|sep|oct|nov|dec)\ed\ed$/ |
132 |
data> 23ja\eP\eD |
data> 23ja\eP\eD |
133 |
Partial match: 23ja |
Partial match: 23ja |
134 |
data> n05\eR\eD |
data> n05\eR\eD |
159 |
always produce exactly the same result as matching over one single long string. |
always produce exactly the same result as matching over one single long string. |
160 |
The difference arises when there are multiple matching possibilities, because a |
The difference arises when there are multiple matching possibilities, because a |
161 |
partial match result is given only when there are no completed matches in a |
partial match result is given only when there are no completed matches in a |
162 |
call to fBpcre_dfa_exec()\fP. This means that as soon as the shortest match has |
call to \fBpcre_dfa_exec()\fP. This means that as soon as the shortest match has |
163 |
been found, continuation to a new subject segment is no longer possible. |
been found, continuation to a new subject segment is no longer possible. |
164 |
Consider this \fBpcretest\fP example: |
Consider this \fBpcretest\fP example: |
165 |
.sp |
.sp |
200 |
where no string can be a partial match for both alternatives. |
where no string can be a partial match for both alternatives. |
201 |
. |
. |
202 |
. |
. |
203 |
.P |
.SH AUTHOR |
204 |
.in 0 |
.rs |
205 |
Last updated: 30 November 2006 |
.sp |
206 |
.br |
.nf |
207 |
Copyright (c) 1997-2006 University of Cambridge. |
Philip Hazel |
208 |
|
University Computing Service |
209 |
|
Cambridge CB2 3QH, England. |
210 |
|
.fi |
211 |
|
. |
212 |
|
. |
213 |
|
.SH REVISION |
214 |
|
.rs |
215 |
|
.sp |
216 |
|
.nf |
217 |
|
Last updated: 04 June 2007 |
218 |
|
Copyright (c) 1997-2007 University of Cambridge. |
219 |
|
.fi |