std.regex bug? My regex doesn't match what it's supposed to.
Alex Folland
lexlexlex at gmail.com
Thu Feb 3 04:46:26 PST 2011
I'm using std.regex from Phobos 2, which I heard was relatively new. My
regex is supposed to match a time to start playback in a game replay's
file name (usually user-written). It's very adaptive and works
perfectly on http://regextester.com but doesn't match properly with Phobos.
I wrote a test program which displays filenames and the matched timecodes.
It's located here: http://lex.clansfx.co.uk/projects/wagametimecodes.d
The regex (might have to widen your mail client to see it properly):
((start|begin|enter|play(back)?)[\s_-]*)?((@|at|from)[\s_-]*)?(\d+([\.\-']|[\s_-]*|m(in(ute)?)?|[\s_-]*and[\s_-]*)*(s(ec(ond)?)?)?){1,3}
\_____________Ignore this part.__It works
perfectly._________/\_______________This part is supposed to match time
codes._______________/
The problematic string:
Guaton_at_9min59sec.WAgame
regextester.com matches "at_9min59sec" altogether perfectly, which is
what I want to happen.
std.regex matches "at_9" and "59s", which I don't want to happen.
std.regex was matching "at_9min59s" before I changed the way it finds
variations of "minute" and "second" from "[ms][inutecond]*" to its
current method. It was better before. Now the numbers aren't even joined.
All in all, I'm pretty sure this is a std.regex bug, but I don't want to
waste Andrei's time if it's not, since I'm not that experienced.
More information about the Digitalmars-d-learn
mailing list