]>
Commit | Line | Data |
---|---|---|
7c673cae FG |
1 | [/ |
2 | Copyright 2006-2007 John Maddock. | |
3 | Distributed under the Boost Software License, Version 1.0. | |
4 | (See accompanying file LICENSE_1_0.txt or copy at | |
5 | http://www.boost.org/LICENSE_1_0.txt). | |
6 | ] | |
7 | ||
8 | ||
9 | [section:leftmost_longest_rule The Leftmost Longest Rule] | |
10 | ||
11 | Often there is more than one way of matching a regular expression at a | |
12 | particular location, for POSIX basic and extended regular expressions, | |
13 | the "best" match is determined as follows: | |
14 | ||
15 | # Find the leftmost match, if there is only one match possible at | |
16 | this location then return it. | |
17 | # Find the longest of the possible matches, along with any ties. | |
18 | If there is only one such possible match then return it. | |
19 | # If there are no marked sub-expressions, then all the remaining | |
20 | alternatives are indistinguishable; return the first of these found. | |
21 | # Find the match which has matched the first sub-expression in the | |
22 | leftmost position, along with any ties. If there is only on such | |
23 | match possible then return it. | |
24 | # Find the match which has the longest match for the first sub-expression, | |
25 | along with any ties. If there is only one such match then return it. | |
26 | # Repeat steps 4 and 5 for each additional marked sub-expression. | |
27 | # If there is still more than one possible match remaining, then they are | |
28 | indistinguishable; return the first one found. | |
29 | ||
30 | [endsect] | |
31 | ||
32 |