Boost logo

Boost :

From: John Maddock (John_Maddock_at_[hidden])
Date: 2001-12-22 07:32:15


>A related but different question: oughtn't the empty string be
>considered a valid regular expression in its own right, i.e.: is it
>really necessary and/or desirable that the declaration
>
>boost::regex cc("");
>
>throws an exception, instead of creating a regex object that matches
>the empty string (and nothing else)? Such a regex object would
>admittedly be rather pointless together with the regex_search
>function, but it makes perfect sense when used with regex_match.
>
>The reason I am asking is not entirely philisophical, because I would
>actually need this functionality in code that I am writing right now,
>but if there are reasons against changing the general regex package I
>can of course easily make a workaround in my own code.

I think retaining that as an error better protects the user from
"unintended consequences", and it is an error according to the POSIX spec I
think. Don't forget that you can use "^" as an expression if you really
want to match a null string.

- John Maddock
http://ourworld.compuserve.com/homepages/john_maddock/


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk