21 Jul
2021
21 Jul
'21
10:57 p.m.
On 22/07/2021 3:19 am, Phil Endecott wrote:
Here's an example of the sort of thing I have:
if (!regexp_match(s, regex("[A-Za-z0-9-_/]{1,8192}"))) throw MalformedInput();
The Javascript equivalent seems to be fine. In C++, with libstdc++'s regex implementation, it seems to take about 2 seconds to run. Boost.Regex didn't like the '-' after the '9' but when I fixed that the execution time became negligible. Boost.Xpressive seems also to be fast.
In pretty much all regexp languages, if you want to match '-' inside a character set then you must specify it as the first character (immediately following the '['), otherwise it is confused as a range specifier.