Beefy Boxes and Bandwidth Generously Provided by pair Networks
The stupid question is the question not asked
 
PerlMonks  

by Samn (Monk)
on Aug 01, 2002 at 02:48 UTC ( [id://186662]=perlquestion: print w/replies, xml ) Need Help??

Samn has asked for the wisdom of the Perl Monks concerning the following question:

Replies are listed 'Best First'.
Re: regex question
by Zaxo (Archbishop) on Aug 01, 2002 at 03:32 UTC

    use HTML::Parser;

    It handles maniacal markup you'll never think of in your homerolled regexen

    Update: ++mkmcconn suggested I add HTML::TokeParser to the recommendation, and I agree (I knew I was forgetting a good one)

    After Compline,
    Zaxo

Re: regex question
by krusty (Hermit) on Aug 01, 2002 at 03:15 UTC
    $body =~ s/<img src=(.*?)>/[image:<a href=$1>$1</a>]/gi;
    Sounds like this might be what you're looking for.

    Cheers,
    kln
Re: regex question
by Abigail-II (Bishop) on Aug 01, 2002 at 09:44 UTC
    You already identified one of the problems (and solutions have been suggested for that), but let me point out that your regex won't work either if there's whitespace between "src" and "=".

    BTW, HTML doesn't have alt tags. HTML has alt attributes - which have been mandatory for IMG tags for quite some time.

    Abigail

186663
by Samn (Monk) on Aug 01, 2002 at 02:50 UTC

    Log In?
    Username:
    Password:

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

    How do I use this?Last hourOther CB clients
    Other Users?
    Others romping around the Monastery: (6)
    As of 2024-04-18 18:03 GMT
    Sections?
    Information?
    Find Nodes?
    Leftovers?
      Voting Booth?

      No recent polls found