POSIX regular expressions (was: autodetecting MBR location)
Tollef Fog Heen <firstname.lastname@example.org> wrote:
>* (Colin Watson)
>| Contrary to the subconscious assumption many people make, the first
>| priority for a regex is to match earliest, not to match longest.
>| regex(7) specifically mentions this:
>For a non-POSIX regex, that is.
Could you point me to some documentation about this? regex(7) claims to
describe POSIX 1003.2 regular expressions, and describes leftmost-first
behaviour. regcomp(3) claims to describe POSIX regex compilation and
execution, and refers to regex(7) and the GNU regex manual for further
documentation. The GNU regex manual (assuming this means the
documentation in librx1g-dev) is ambiguous: it says "In every case like
this, the longer match is preferred", but the example it gives is one of
alternative subexpressions rather than an earliest vs. longest issue.
Furthermore, a brief test program produces output consistent with
earliest matches against both libc6 and librx1g, both of which claim to
provide POSIX regex engines. So is there no correct POSIX regex library
Colin Watson [email@example.com]