Beefy Boxes and Bandwidth Generously Provided by pair Networks
Do you know where your variables are?
 
PerlMonks  

Re: extract a specific string from input

by clueless newbie (Friar)
on Sep 26, 2012 at 11:30 UTC ( #995748=note: print w/ replies, xml ) Need Help??


in reply to extract a specific string from input

.* will get you the longest sequence of characters.

.*? will get you the shortest sequence.


Comment on Re: extract a specific string from input
Re^2: extract a specific string from input
by moritz (Cardinal) on Sep 26, 2012 at 11:57 UTC
    .*? will get you the shortest sequence.

    Usually that's correct, but not if there is overlap between the stand and the end delimiter. ATTAA is the shortest sequence that begins wtih ATT and ends with TAA, but ATT.*?TAA doesn't match it.

    If overlapping matches need to be allowed, you can use for example

    /((?=ATT).*?TAA)/

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others making s'mores by the fire in the courtyard of the Monastery: (12)
As of 2014-09-17 16:06 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    How do you remember the number of days in each month?











    Results (91 votes), past polls