Beefy Boxes and Bandwidth Generously Provided by pair Networks
There's more than one way to do things
 
PerlMonks  

Re^4: Regex Extraction Help

by Flexx (Pilgrim)
on Aug 09, 2012 at 22:08 UTC ( #986617=note: print w/replies, xml ) Need Help??


in reply to Re^3: Regex Extraction Help
in thread Regex Extraction Help

« Based upon the OP's regex, it appears that the pattern's stable--with one space after the semi-colon »

Oh indeed, my "warning" was meant more like a general tip, I didn't just mean this particular example. Just meant to say that it's a difference in how split vs if(m//) with some rather "strict" regexp typically result in a different level of defensiveness of the code. Again, I mean just typically. I mean hey, "just use split" would've been first answer, too. But you wrote that already, so I had to come up with something nitpicking. ;)

« However, we can ask split to 'test' the format of the input »

Umm... ok, you wrote 'test' in quotes, so alright... ;)

Sure, you can combine the split and trim operation, but still, this split would happily work on any input you throw at it (including undef, with a warning, though). It won't tell you (by not even matching) that your input looks a bit strange there.

Now, again, I am not so much talking about the OP's concrete problem, but was trying to educate a bit on what method to use when, since his usage of \d\d\d\d\d instead of \d{5} suggested that regexen ain't something he works with since years (No offence meant.)

So long,
Flexx

Replies are listed 'Best First'.
Re^5: Regex Extraction Help
by Kenosis (Priest) on Aug 09, 2012 at 22:16 UTC

    You make more good points, and am glad you offered the "general tip," as it helps with developing good programming practices. Anticipating and coding for exceptions can (and does) save many headaches...

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://986617]
help
Chatterbox?
[Discipulus]: ah! so you mean if i need a static image i can use Twig, if on the fly better css selector and mody attrs (jquery?), rigth?
[LanX]: not sure what you guys are taking about, but a DOM manipulation in JS shouldn't be difficult
[Corion]: Discipulus: Yeah, that's what I would try (but so far, I can't even change the colors manually in the SVG, which is why I gave up ;) )
Discipulus bad sign..
[Discipulus]: italian doc says to modify somehow the initial SVG before using it with D3.js
[Discipulus]: LanX the fact is that my js ability is even poorer than my Perl one..
[LanX]: oh its negative? ;P
[Discipulus]: my warmest comprehension karlgoethebier ;=(

How do I use this? | Other CB clients
Other Users?
Others surveying the Monastery: (13)
As of 2017-03-23 09:48 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Should Pluto Get Its Planethood Back?



    Results (285 votes). Check out past polls.