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"; }

Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
"Science is about questioning the status quo. Questioning authority".
In the absence of evidence, opinion is indistinguishable from prejudice.

Replies are listed 'Best First'.
Re^2: Possible with a regex?
by ultranerds (Hermit) on May 23, 2011 at 15:51 UTC
    Hi,

    Thanks - your second option works perfectly :)

    Cheers

    Andy