siddheshsawant has asked for the wisdom of the Perl Monks concerning the following question:
Hello friends , I have a string which is URL like this:
"http://192.162.143.201/nightly_results/2009_12_02/log_lcla114.ping.com_64.html"
I wants to extract only "log_lcla114.ping.com_64.html" out of above whole string..I tried to extract it but I couldnot able to get success..My code and corresponding output is as follows
#!/usr/bin/perl -w use strict; my $mystring = "http://192.162.143.201/nightly_results/2009_12_02/log_ +lcla114.ping.com_64.html"; if($mystring =~ m!([^/]+)!){ my $file=$1; print "field= $file\n"; }
I got output like this:
field= http:
where as I expect to get "log_lcla114.ping.com_64.html" can anybody rectify my regex to get desired output....Thanks in advance !!!!!
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: A question on Regex
by ssandv (Hermit) on Mar 24, 2010 at 19:43 UTC | |
|
Re: A question on Regex
by kennethk (Abbot) on Mar 24, 2010 at 19:44 UTC | |
by siddheshsawant (Sexton) on Mar 24, 2010 at 19:47 UTC | |
|
Re: A question on Regex
by Your Mother (Archbishop) on Mar 24, 2010 at 19:53 UTC | |
|
Re: A question on Regex
by Anonymous Monk on Mar 24, 2010 at 19:48 UTC | |
|
Re: A question on Regex
by kiruthika.bkite (Scribe) on Mar 25, 2010 at 04:02 UTC |