in reply to Possible with a regex?
If you can assume that urls will not contain (unencoded) spaces, then this might work for you:
my $test = qq| sdfiojs pfojsdfs fs [img]sdj fpsdofj spojf sfsf [b] [img]http://www.te +st.com/image.gif[/img] dfs fs s fsf sfd [img]test.gif[/img] |; while ($test =~ /\[img\](\S+?)\[\/img\]/g) { print "$1 \n"; } __END__ c:\test>junk http://www.test.com/image.gif test.gif
Alternatively, maybe this is better:
while ($test =~ /\[img\]([^\[\]]+?)\[\/img\]/g) { print "$1 \n"; }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Possible with a regex?
by ultranerds (Hermit) on May 23, 2011 at 15:51 UTC |