CGI/Perl Guide | Learning Center | Forums | Advertise | Login
Site Search: in

  Main Index MAIN
INDEX
Search Posts SEARCH
POSTS
Who's Online WHO'S
ONLINE
Log in LOG
IN

Home: Perl Programming Help: Beginner:
regular expression, smallest match

 



orange
Novice

May 27, 2013, 3:25 AM

Post #1 of 3 (320 views)
regular expression, smallest match Can't Post

it seems by default, it matches as much as possible ('greedy'). I need it to match as less as possible. how to do it?
thanks.


(This post was edited by orange on May 27, 2013, 3:26 AM)


BillKSmith
Veteran

May 27, 2013, 4:02 AM

Post #2 of 3 (317 views)
Re: [orange] regular expression, smallest match [In reply to] Can't Post

All of the quantifiers ({n,m}, {n,}, {n}, *, +, ?) are greedy. They all have an equivalent non-greedy version ({n,m}?, {n,}?, {n}?, *?, +?, ??).

UPDATE: Fixed typo in non-greedy version of {n}.
Good Luck,
Bill

(This post was edited by BillKSmith on May 27, 2013, 8:01 AM)


orange
Novice

May 27, 2013, 4:58 AM

Post #3 of 3 (315 views)
Re: [BillKSmith] regular expression, smallest match [In reply to] Can't Post

that is fantastic. thank you very much Bill.

 
 


Search for (options) Powered by Gossamer Forum v.1.2.0

Web Applications & Managed Hosting Powered by Gossamer Threads
Visit our Mailing List Archives