Beefy Boxes and Bandwidth Generously Provided by pair Networks
Your skill will accomplish
what the force of many cannot
 
PerlMonks  

Re^2: Capture groups

by nefigah (Monk)
on Mar 05, 2008 at 00:49 UTC ( #672054=note: print w/ replies, xml ) Need Help??


in reply to Re: Capture groups
in thread Capture groups

For some reason I'm using the regex but its not working:
That is a pretty specific regex... will none of your text chunks be only 1 word? Also, the 2nd \s may cause a problem if the number is separated from the text by multiple tabs/spaces.


Comment on Re^2: Capture groups
Download Code
Re^3: Capture groups
by ww (Bishop) on Mar 05, 2008 at 12:46 UTC
    Again (cf above) making \s match multiple whitespace -- tabs or spaces, to judge from OP - is easily handled with a "+" after the second \s.

    The point about the possibility of single word "text chunks" is well made... so long as the words "pretty specific regex" are not intended to deprecate specificity.

    IMO, specificity is *GOOD* in a regex unless ambiguity (or at least, specific generalizations) are required because a less-than-specific regex can lead to hard-to-find problems where the source data includes unexpected content.

    Consider,

    H2O     60%
    or
    Grand Canyon3     70%
    or
    Teller-Bose condensate     50%

    Does one want the "water" entry or the footnoted "Grand Canyon" in the output?

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://672054]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others browsing the Monastery: (11)
As of 2014-10-21 10:57 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    For retirement, I am banking on:










    Results (100 votes), past polls