Beefy Boxes and Bandwidth Generously Provided by pair Networks
Just another Perl shrine

Re: Regex Question

by sundialsvc4 (Abbot)
on Jan 22, 2013 at 16:14 UTC ( #1014715=note: print w/replies, xml ) Need Help??

in reply to Regex Question

One thing that you need to keep in mind when building regexes like these is the subject of greedy.   By default, the regex will (“greedily ...”) find the longest available string that matches.   You can specify that it should, instead, opt for the shortest one, and sometimes (depending on the nature of the string that is to be processed) you must do that.

I also strongly advocate that your programming should be suspicious of its input files.   If you expect 5 strings, check each time that you have them.   In short, if you can be certain of anything in the correctly-running program given correct data, “be from MIssouri ... show me.”   Quite frankly, most of the time, I’ve encountered broken data.   The supplier of the data didn’t know it was broken.   “Inexplicable bugs” turned out to be from that cause.   Only the computer itself is in the necessary position to recognize the existence of these issues ... take the slight extra time to make it do so.

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1014715]
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others avoiding work at the Monastery: (3)
As of 2018-02-25 00:38 GMT
Find Nodes?
    Voting Booth?
    When it is dark outside I am happiest to see ...

    Results (312 votes). Check out past polls.