# Diff of /code/trunk/doc/pcrematching.3

revision 571 by ph10, Fri Oct 22 15:57:50 2010 UTC revision 572 by ph10, Wed Nov 17 17:55:57 2010 UTC
# Line 83  The scan continues until either the end Line 83  The scan continues until either the end
83  no more unterminated paths. At this point, terminated paths represent the  no more unterminated paths. At this point, terminated paths represent the
84  different matching possibilities (if there are none, the match has failed).  different matching possibilities (if there are none, the match has failed).
85  Thus, if there is more than one possible match, this algorithm finds all of  Thus, if there is more than one possible match, this algorithm finds all of
86  them, and in particular, it finds the longest. There is an option to stop the  them, and in particular, it finds the longest. The matches are returned in
87  algorithm after the first match (which is necessarily the shortest) is found.  decreasing order of length. There is an option to stop the algorithm after the
88    first match (which is necessarily the shortest) is found.
89  .P  .P
90  Note that all the matches that are found start at the same point in the  Note that all the matches that are found start at the same point in the
91  subject. If the pattern  subject. If the pattern
92  .sp  .sp
93    cat(er(pillar)?)    cat(er(pillar)?)?
94  .sp  .sp
95  is matched against the string "the caterpillar catchment", the result will be  is matched against the string "the caterpillar catchment", the result will be
96  the three strings "cat", "cater", and "caterpillar" that start at the fourth  the three strings "caterpillar", "cater", and "cat" that start at the fifth
97  character of the subject. The algorithm does not automatically move on to find  character of the subject. The algorithm does not automatically move on to find
98  matches that start at later positions.  matches that start at later positions.
99  .P  .P
# Line 151  callouts. Line 152  callouts.
152  2. Because the alternative algorithm scans the subject string just once, and  2. Because the alternative algorithm scans the subject string just once, and
153  never needs to backtrack, it is possible to pass very long subject strings to  never needs to backtrack, it is possible to pass very long subject strings to
154  the matching function in several pieces, checking for partial matching each  the matching function in several pieces, checking for partial matching each
155  time. It is possible to do multi-segment matching using \fBpcre_exec()\fP (by  time. Although it is possible to do multi-segment matching using the standard
156  retaining partially matched substrings), but it is more complicated. The  algorithm (\fBpcre_exec()\fP), by retaining partially matched substrings, it is
157    more complicated. The
158  .\" HREF  .\" HREF
159  \fBpcrepartial\fP  \fBpcrepartial\fP
160  .\"  .\"
# Line 189  Cambridge CB2 3QH, England. Line 191  Cambridge CB2 3QH, England.
191  .rs  .rs
192  .sp  .sp
193  .nf  .nf
194  Last updated: 22 October 2010  Last updated: 17 November 2010
195  Copyright (c) 1997-2010 University of Cambridge.  Copyright (c) 1997-2010 University of Cambridge.
196  .fi  .fi

Legend:
 Removed from v.571 changed lines Added in v.572