Michael Goopta wrote:
I am new to Perl. How can I split the below string and get the multiple web-addresses in a list: (i.e. the strings between <upsl-url> and </upsl-url> <upsl-url>http://view-preprod.admission.net/abc/mactive/_NJMG_0002029003-01/i-1.JPG?t=tr/m:FitPad/w:199/h:124&t=ts/r:199x199</upsl-url><upsl-url>http://view-preprod.admission.net/abc/mactive/_NJMG_0002029003-01/i-1.JPG?t=tr/m:FitPad/w:199/h:124&t=ts/r:199x199</upsl-url> </ad-type> Any help is appreciated.
Hi Michael The following code will extract all substrings consisting of of 'http:' and all following characters that aren't '<'. The two URLs appear to be identical in your example. Hope this helps, Rob use strict; use warnings; my $text = '<upsl-url>http://view-preprod.admission.net/abc/mactive/_NJMG_0002029003-01/i-1.JPG?t=tr/m:FitPad/w:199/h:124&t=ts/r:199x199</upsl-url><upsl-url>http://view-preprod.admission.net/abc/mactive/_NJMG_0002029003-01/i-1.JPG?t=tr/m:FitPad/w:199/h:124&t=ts/r:199x199</upsl-url>'; my @urls = $text =~ /http:[^<]+/g; print "$_\n" foreach @urls; **OUTPUT** http://view-preprod.admission.net/abc/mactive/_NJMG_0002029003-01/i-1.JPG?t=tr/m:FitPad/w:199/h:124&t=ts/r:199x199 http://view-preprod.admission.net/abc/mactive/_NJMG_0002029003-01/i-1.JPG?t=tr/m:FitPad/w:199/h:124&t=ts/r:199x199 -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/