81 |
uses the date example quoted above: |
uses the date example quoted above: |
82 |
.sp |
.sp |
83 |
re> /^\ed?\ed(jan|feb|mar|apr|may|jun|jul|aug|sep|oct|nov|dec)\ed\ed$/ |
re> /^\ed?\ed(jan|feb|mar|apr|may|jun|jul|aug|sep|oct|nov|dec)\ed\ed$/ |
84 |
data> 25jun04\P |
data> 25jun04\eP |
85 |
0: 25jun04 |
0: 25jun04 |
86 |
1: jun |
1: jun |
87 |
data> 25dec3\P |
data> 25dec3\eP |
88 |
Partial match |
Partial match |
89 |
data> 3ju\P |
data> 3ju\eP |
90 |
Partial match |
Partial match |
91 |
data> 3juj\P |
data> 3juj\eP |
92 |
No match |
No match |
93 |
data> j\P |
data> j\eP |
94 |
No match |
No match |
95 |
.sp |
.sp |
96 |
The first data string is matched completely, so \fBpcretest\fP shows the |
The first data string is matched completely, so \fBpcretest\fP shows the |
175 |
.P |
.P |
176 |
Because of this phenomenon, it does not usually make sense to end a pattern |
Because of this phenomenon, it does not usually make sense to end a pattern |
177 |
that is going to be matched in this way with a variable repeat. |
that is going to be matched in this way with a variable repeat. |
178 |
|
.P |
179 |
|
4. Patterns that contain alternatives at the top level which do not all |
180 |
|
start with the same pattern item may not work as expected. For example, |
181 |
|
consider this pattern: |
182 |
|
.sp |
183 |
|
1234|3789 |
184 |
|
.sp |
185 |
|
If the first part of the subject is "ABC123", a partial match of the first |
186 |
|
alternative is found at offset 3. There is no partial match for the second |
187 |
|
alternative, because such a match does not start at the same point in the |
188 |
|
subject string. Attempting to continue with the string "789" does not yield a |
189 |
|
match because only those alternatives that match at one point in the subject |
190 |
|
are remembered. The problem arises because the start of the second alternative |
191 |
|
matches within the first alternative. There is no problem with anchored |
192 |
|
patterns or patterns such as: |
193 |
|
.sp |
194 |
|
1234|ABCD |
195 |
|
.sp |
196 |
|
where no string can be a partial match for both alternatives. |
197 |
. |
. |
198 |
. |
. |
199 |
.P |
.P |
200 |
.in 0 |
.in 0 |
201 |
Last updated: 28 February 2005 |
Last updated: 16 January 2006 |
202 |
.br |
.br |
203 |
Copyright (c) 1997-2005 University of Cambridge. |
Copyright (c) 1997-2006 University of Cambridge. |