Beefy Boxes and Bandwidth Generously Provided by pair Networks
P is for Practical
 
PerlMonks  

Re: Eugh, regex :(

by svenXY (Deacon)
on Mar 25, 2009 at 10:06 UTC ( [id://753083]=note: print w/replies, xml ) Need Help??


in reply to Eugh, regex :(

Hi,
your regex was far too sophisticated IMHO.
#!/usr/bin/perl use strict; use warnings; use re "debug"; # will help you understand your regexes my $post_message = '[URL=http://img207.imageshack.us/my.php?image=dsc0 +3598vt7.jpg]' . '[IMG]http://img207.imageshack.us/img207/2964/dsc03 +598vt7.jpg[/IMG][/URL]'; my @fields = $post_message =~ m#\Q[URL=\E([^]]+)\Q][img]\E([^]]+)\Q[/i +mg][/URL]\E#gix; ## ^^^ one or more of not ']' ## should be enough here. print join("\n", @fields, "\n");

Regards,
svenXY

Replies are listed 'Best First'.
Re^2: Eugh, regex :(
by ultranerds (Hermit) on Mar 25, 2009 at 11:35 UTC
    Hi,

    Thanks for the reply :) Although your example works (all tested out fine), I still can't get it going in my script :(

    print STDERR qq|\n\n---------------------------OLD post was: $ +post_message\n\n---------------------------|; $post_message =~ s|\Q[URL=\E([^]]+)\Q][IMG]\E([^]]+)\Q[/IMG][/ +URL]\E|$2|sig; print STDERR qq|\n\n---------------------------new post was: $ +post_message\n\n---------------------------|; <code> <br /><br /> All that does, is print out: <br /><br /> <code>---------------------------OLD post was: sdfsdfsdfsdf [img]http://images.voyageforum.org/photos/thumbs/0/73780-04_34_2---com +puter-keyboard_web.jpg[/img] [URL=http://img207.imageshack.us/my.php?image=dsc03598vt7.jpg][IMG=htt +p://img207.imageshack.us/img207/2964/dsc03598vt7.jpg][/IMG][/URL] [signature] --------------------------- ---------------------------new post was: sdfsdfsdfsdf [img]http://images.voyageforum.org/photos/thumbs/0/73780-04_34_2---com +puter-keyboard_web.jpg[/img] [URL=http://img207.imageshack.us/my.php?image=dsc03598vt7.jpg][IMG=htt +p://img207.imageshack.us/img207/2964/dsc03598vt7.jpg][/IMG][/URL] [signature] ---------------------------


    (as you can see, it hasn't been edited at all :()

    Any more ideas? Otherwise, just gonna call it quits with this til after I get back from vacation - maybe looking at it with fresh eyes will reveal something :/

    TIA

    Andy

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://753083]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others rifling through the Monastery: (4)
As of 2024-04-24 04:58 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found