ultranerds has asked for the wisdom of the Perl Monks concerning the following question:
..gives me: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\](.+?)\[\/img\]/g) { print "$1 \n"; }
What I need really, is:C:\Users\Andy>perl test.pl sdj fpsdofj spojf sfsf [b] [img]http://www.test.com/image.gi test.gif
Is this possible? I could do it inside the while () loop, by checking the value - but if possible, I would prefer to just do it in a regex :)C:\Users\Andy>perl test.pl http://www.test.com/image.gif test.gif
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Possible with a regex?
by BrowserUk (Patriarch) on May 23, 2011 at 15:43 UTC | |
by ultranerds (Hermit) on May 23, 2011 at 15:51 UTC | |
|
Re: Possible with a regex?
by Corion (Patriarch) on May 23, 2011 at 15:49 UTC | |
by ultranerds (Hermit) on May 23, 2011 at 15:55 UTC | |
|
Re: Possible with a regex?
by wind (Priest) on May 23, 2011 at 17:10 UTC | |
|
Re: Possible with a regex?
by John M. Dlugosz (Monsignor) on May 23, 2011 at 17:40 UTC | |
|
Re: Possible with a regex?
by JavaFan (Canon) on May 23, 2011 at 19:11 UTC |