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: Intermediate:
pattern matching

 



zaebanB
New User

Feb 2, 2007, 7:49 AM

Post #1 of 2 (253 views)
pattern matching Can't Post

hello,

$string = '<start "some string" "other string" " ">';

$string =~ /<start(\".*\").*>/;

when i'm doing this $1 is equal to "some string" "other string" " "

but I want to extract only "some string".

Can you help me?
Thank you


ProBulletin
Novice

Feb 2, 2007, 9:15 AM

Post #2 of 2 (252 views)
Re: [zaebanB] pattern matching [In reply to] Can't Post


Code
$string =~ /<start (".*?")/g;


Use .*? instead of .* so the regex is non-greedy.


Regards,
Paul Wilson
ProBulletin Board: http://www.probulletin.com/


(This post was edited by ProBulletin on Feb 2, 2007, 9:15 AM)

 
 


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

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