leftmost_longest.qbk 1.3 KB

1234567891011121314151617181920212223242526272829303132
  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. [section:leftmost_longest_rule The Leftmost Longest Rule]
  8. Often there is more than one way of matching a regular expression at a
  9. particular location, for POSIX basic and extended regular expressions,
  10. the "best" match is determined as follows:
  11. # Find the leftmost match, if there is only one match possible at
  12. this location then return it.
  13. # Find the longest of the possible matches, along with any ties.
  14. If there is only one such possible match then return it.
  15. # If there are no marked sub-expressions, then all the remaining
  16. alternatives are indistinguishable; return the first of these found.
  17. # Find the match which has matched the first sub-expression in the
  18. leftmost position, along with any ties. If there is only on such
  19. match possible then return it.
  20. # Find the match which has the longest match for the first sub-expression,
  21. along with any ties. If there is only one such match then return it.
  22. # Repeat steps 4 and 5 for each additional marked sub-expression.
  23. # If there is still more than one possible match remaining, then they are
  24. indistinguishable; return the first one found.
  25. [endsect]