www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.learn - Re: std.regex bug? My regex doesn't match what it's supposed to.

reply Jesse Phillips <jessekphillips+D gmail.com> writes:
Alex Folland Wrote:


 The problematic string:
 
 Guaton_at_9min59sec.WAgame

Might I suggest using a simpler regex? It gives the ability to do better error checking/reporting. Instead of adding all the misspellings for minute and second, just capture those locations as words and analyze them outside the regex. In fact you could capture the whole time segment and use a second regex to pull out the data: regex("(\d+\w+)", "g") Then your regex isn't updated when you need to add hours and such.
Feb 03 2011
parent Alex Folland <lexlexlex gmail.com> writes:
On 2011-02-03 17:03, Jesse Phillips wrote:
 Alex Folland Wrote:


 The problematic string:

 Guaton_at_9min59sec.WAgame

Might I suggest using a simpler regex? It gives the ability to do better error checking/reporting. Instead of adding all the misspellings for minute and second, just capture those locations as words and analyze them outside the regex. In fact you could capture the whole time segment and use a second regex to pull out the data: regex("(\d+\w+)", "g") Then your regex isn't updated when you need to add hours and such.

I finished my function today. :) I did end up using shorter regexes and embedded foreach loops in order to break the timecodes down. However, the whole timecodes were found by a relatively large and adaptive regex, which seems to be necessary. Thanks for the tip though. It helped further down the line.
Feb 04 2011