[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
posix-string-match does not distinguish "*" from "*?"
From: |
Matt Swift |
Subject: |
posix-string-match does not distinguish "*" from "*?" |
Date: |
Sun, 16 Feb 2003 00:58:33 -0500 |
User-agent: |
Gnus/5.090016 (Oort Gnus v0.16) Emacs/21.2 |
`posix-string-match' (and I presume the other `posix-*' searching
functions) do not seem to distinguish between the "*" and "*?"
operators. No mention is made of this difference from `string-match'
in the Elisp manual, which describes the posix- functions as having
super-greedy repetition constructs and handling of "|", but a reader
would not guess that these functions differ with respect to the
explicitly non-greedy operators "*?", "+?" and "??". Since I do not
have access to the POSIX specs, someone else will have to discern
whether this is a dox bug or a bug in `posix-string-match'.
This is the example from the manual description of the non-greedy operators:
(let ((s "cdaaada")
(rshort "c[ad]*?a"))
(list
(progn
(string-match rshort s)
(match-string 0 s))
(progn
(posix-string-match rshort s)
(match-string 0 s))
))
=> ("cda" "cdaaada")
node (elisp)POSIX Regexps:
The usual regular expression functions do backtracking when necessary
to handle the `\|' and repetition constructs, but they continue this
only until they find _some_ match. Then they succeed and report the
first match found.
This section describes alternative search functions which perform the
full backtracking specified by the POSIX standard for regular expression
matching. They continue backtracking until they have tried all
possibilities and found all matches, so they can report the longest
match, as required by POSIX. This is much slower, so use these
functions only when you really need the longest match.
- posix-string-match does not distinguish "*" from "*?",
Matt Swift <=