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 expressions ...

 



yaniv_av
Novice

Nov 4, 2002, 3:14 AM

Post #1 of 3 (312 views)
regular expressions ... Can't Post

suppose I have the string:
"a=13 ytr hg a=15 bry dga=19gg a=998 p"
I want to get all the occurences of the
pattern /a=.* / (into an array)
But I want only the expression a=*. and that's all (gready selection)
In this case I want to get as the result an array that contain:
@result=("a=13","a=15","a=998")
How can I do that ?


Paul
Enthusiast

Nov 4, 2002, 4:01 AM

Post #2 of 3 (310 views)
Re: [yaniv_av] regular expressions ... [In reply to] Can't Post


Code
my $string = "a=13 ytr hg a=15 bry dga=19gg a=998 p"; 
my @result = $string =~ /(\w+=\d+)/g;

print "Content-type: text/plain\n\n";
print join "\n", @result;



yaniv_av
Novice

Nov 5, 2002, 1:57 PM

Post #3 of 3 (300 views)
Re: [RedRum] regular expressions ... [In reply to] Can't Post

And if I want as the result only the numbers ?
In this case: @result=(13,15,998)

 
 


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

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