Saya wrote: > > I have the following issue: > > my $s = "/metadata-files/test-desc.txt,/metadata-files/birthday.txt,/ > web-media/images/bday-after-help.jpg,javascript:popUp('/pop-ups/ > birthday/main.html','bday-pics',785,460);" > > Now I want $s to be like: "/metadata-files/test-desc.txt,/metadata- > files/birthday.txt,/web-media/images/bday-after-help.jpg,/pop-ups/ > birthday/main.html" > > I have been working with: > > $s =~ s/javascript:popup\('(.*)',(.*)/$1/gi; > > But this gives me $s looking like this: "/metadata-files/levemir- > desc.txt,/metadata-files/levemir-keywords.txt,/web-media/images/ > img_insulin_interactive.jpg,/pop-ups/why-insulin/ > main.html','quickguide'" > > How can I only I achieve what I am trying to ? > Any help or hints will be greatly appreciated.
$s =~ s/javascript:popUp\('(.*?)'.*/$1/; does what you want. But without seeing all of the possible data you have I can't be sure that it will work in every case. The main mistake you made was to use a greedy capture /(.*)/ which will match up to the last single-quote in the string, instead of a non-greedy one /(.*?)/ which will match only up to the next single-quote. You also have an unnecessary capture around the trailing /.*/ which is wasteful but will not cause the substitution to fail. HTH, Rob -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/