• Home
  • Raw
  • Download

Lines Matching full:is

7 In normal use of PCRE2, if the subject string that is passed to a matching
8 function matches as far as it goes, but is too short to match the entire
9 pattern, PCRE2_ERROR_NOMATCH is returned. There are circumstances where it
10 might be helpful to distinguish this case from other cases in which there is no
13 Consider, for example, an application where a human is required to type in data
20 what has been typed so far is potentially valid, it is able to raise an error
21 as soon as a mistake is made, by beeping and not reflecting the character that
22 has been typed, for example. This immediate feedback is likely to be a better
23 user interface than a check that is delayed until the entire string has been
24 entered. Partial matching can also be useful when the subject string is very
25 long and is not all available at once.
29 The difference between the two options is whether or not a partial match is
42 interpretive matching code is used.
46 abandons matching immediately if it is not present in the subject string. This
57 subject string is reached successfully, but matching cannot continue because
66 When a partial match is returned, the first two elements in the ovector point
73 If it is matched against "456abc123xyz" the result is a complete match, and the
75 match" point. However, if a partial match is requested and the subject string
76 is "456abc12", a partial match is found for the string "abc12", because all
80 What happens when a partial match is identified depends on which of the two
87 If PCRE2_PARTIAL_SOFT is set when \fBpcre2_match()\fP identifies a partial
88 match, the partial match is remembered, but matching continues as normal, and
90 PCRE2_ERROR_PARTIAL is returned instead of PCRE2_ERROR_NOMATCH.
92 This option is "soft" because it prefers a complete match over a partial match.
93 All the various matching items in a pattern behave as if the subject string is
95 subject, as normal, and for \eb and \eB the end of the subject is treated as a
98 If there is more than one partial match, the first one that was found provides
99 the data that is returned. Consider this pattern:
103 If this is matched against the subject string "abc123dog", both
104 alternatives fail to match, but the end of the subject is reached during
105 matching, so PCRE2_ERROR_PARTIAL is returned. The offsets are set to 3 and 9,
114 If PCRE2_PARTIAL_HARD is set for \fBpcre2_match()\fP, PCRE2_ERROR_PARTIAL is
115 returned as soon as a partial match is found, without continuing to search for
116 possible complete matches. This option is "hard" because it prefers an earlier
117 partial match over a later complete match. For this reason, the assumption is
120 of the subject, the result is PCRE2_ERROR_PARTIAL, provided that at least one
132 This matches either "dog" or "dogsbody", greedily (that is, it prefers the
133 longer string if possible). If it is matched against the string "dog" with
135 PCRE2_PARTIAL_HARD is set, the result is PCRE2_ERROR_PARTIAL. On the other
136 hand, if the pattern is made ungreedy the result is different:
140 In this case the result is always a complete match because that is found first,
144 /dog(sbody)?/ is the same as /dogsbody|dog/
145 /dog(sbody)??/ is the same as /dog|dogsbody/
156 the subject is reached before the end of the pattern, there is the possibility
160 When PCRE2_PARTIAL_SOFT is set, PCRE2_ERROR_PARTIAL is returned only if there
162 However, if PCRE2_PARTIAL_HARD is set, a partial match takes precedence over
164 longest partial match was found is set as the first matching string.
166 Because the DFA functions always search for all possible matches, and there is
167 no difference between greedy and ungreedy repetition, their behaviour is
168 different from the standard functions when PCRE2_PARTIAL_HARD is set. Consider
175 returns that when PCRE2_PARTIAL_HARD is set.
187 This matches "cat", provided there is a word boundary at either end. If the
188 subject string is "the cat", the comparison of the final "t" with a following
189 character cannot take place, so a partial match is found. However, normal
191 character is a letter, so a complete match is found. The result, therefore, is
199 If the \fBpartial_soft\fP (or \fBps\fP) modifier is present on a
200 \fBpcre2test\fP data line, the PCRE2_PARTIAL_SOFT option is used for the match.
201 Here is a run of \fBpcre2test\fP that uses the date example quoted above:
216 The first data string is matched completely, so \fBpcre2test\fP shows the
218 pattern, but the first two are partial matches. Similar output is obtained
219 if DFA matching is used.
221 If the \fBpartial_hard\fP (or \fBph\fP) modifier is present on a
222 \fBpcre2test\fP data line, the PCRE2_PARTIAL_HARD option is set for the match.
228 When a partial match has been found using a DFA matching function, it is
232 because this is where details of the previous partial match are stored. Here is
243 Notice that when the match is complete, only the last part is shown; PCRE2 does
244 not retain the previously partially-matched string. It is up to the calling
247 That means that, for an unanchored pattern, if a continued match fails, it is
248 not possible to try again at a new starting point. All this facility is capable
249 of doing is continuing with the previous match attempt. In the previous
250 example, if the second set of data is "ug23" the result is no match, even
253 The only way to allow for starting again at the next character is to retain the
265 Unlike the DFA function, it is not possible to restart the previous match with
270 It is best to use PCRE2_PARTIAL_HARD in this situation, because it does not
275 data> The date is 23ja\e=ph
282 processing time is needed.
289 whichever matching function is used.
293 beginning of a line. There is also a PCRE2_NOTEOL option, but in practice when
305 option. Note that the resulting count is in characters, not code units. After a
309 back is just a subtraction, but in UTF-8 or UTF-16 you have to count characters
313 the next segment has been added to what is retained, you should run the next
317 For example, if the pattern "(?<=123)abc" is partially matched against the
319 lookbehind count is 3, so all characters before offset 2 can be discarded. The
342 4. Matching a subject string that is split into multiple segments may not
344 especially when PCRE2_PARTIAL_SOFT is used. The section "Partial Matching and
349 the shortest match has been found, continuation to a new subject segment is no
364 setting the PCRE2_PARTIAL_SOFT option. Although the string is a partial match
365 for "dogsbody", the result is not PCRE2_ERROR_PARTIAL, because the shorter
366 string "dog" is a complete match. Similarly, when the subject is presented to
368 the match stops when "dog" has been found, and it is not possible to continue.
369 On the other hand, if "dogsbody" is presented as a single string, a DFA
372 Because of these problems, it is best to use PCRE2_PARTIAL_HARD when matching
384 with the same pattern item may not work as expected when PCRE2_DFA_RESTART is
389 If the first part of the subject is "ABC123", a partial match of the first
390 alternative is found at offset 3. There is no partial match for the second
395 matches within the first alternative. There is no problem with anchored
400 where no string can be a partial match for both alternatives. This is not a
401 problem if a standard matching function is used, because the entire match has
412 possibility is to work with two buffers. If a partial match at offset \fIn\fP
413 in the first buffer is followed by "no match" when PCRE2_DFA_RESTART is used on