std.regex bug? My regex doesn't match what it's supposed to.

Alex Folland lexlexlex at gmail.com
Fri Feb 4 03:29:56 PST 2011


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.


More information about the Digitalmars-d-learn mailing list