procmail
[Top] [All Lists]

Re: Why was there no error?

2002-01-19 17:16:28
Martin explained,

| The way the procmail regex engine works (and I don't know whether this
| is by accident or design - perhaps Philip knows if it is by design) is
| that the '?', '*' and '+' metacharacters do not always act as
| metacharacters.
|
| In conditions like yours where you have a sequence such as ' ??', the
| first '?' query clearly applies to the space.  The second '?' isn't
| legal as a metacharacter there and so, perhaps surprisingly, it acts as
| a literal questionmark!  ' ??' is a regular expression that will match
| an optional space followed by a question mark.

Thank you.  So it's equivalent to    " ?\?"   ...  I'd rather it had been an
error; then I would have noticed my typo sooner.

| And ' ???' would be an optional space followed by an optional question
| mark.  ' *+??*' would be zero or more spaces, an optional plus sign, and
| zero or more question marks.

Just like  " ?\??"   or  " *\+?\?*"  respectively ... how very
uncomfortable.  I had always believed that the "var ??" syntax for
specifying a search area was selected partly because it wouldn't intefere
with any valid regexps, but it seems instead that it doesn't interfere with
any valid regexp that couldn't be expressed some other way.  I guess that if
the regexp starts with

 <legal variable name><optional single space><literal question mark><space>

you'll need to escape the literal question mark (instead of relying on what
Martin just described), or stick parentheses around part or all of it [but
not between the first space and the first question mark], or put an empty
pair of parentheses in there somewhere [but not after the second space], to
get the entirety read as a regexp.  I'd vote for escaping the literal
question mark or the old reliable trick of starting with an empty pair of
parentheses.

Now I need a nap.



_______________________________________________
procmail mailing list
procmail(_at_)lists(_dot_)RWTH-Aachen(_dot_)DE
http://MailMan.RWTH-Aachen.DE/mailman/listinfo/procmail

<Prev in Thread] Current Thread [Next in Thread>