Beefy Boxes and Bandwidth Generously Provided by pair Networks
Your skill will accomplish
what the force of many cannot

Re: Re: Drop in regex replacements?

by IOrdy (Friar)
on Sep 09, 2002 at 14:58 UTC ( #196290=note: print w/replies, xml ) Need Help??

in reply to Re: Drop in regex replacements?
in thread Drop in regex replacements?

Sorry, I thought it would be quite obvious because above each regex is an example of what I am parsing. :-(
# Process Complex Tags -> [url=""]foobar[/url]
What you suggested would be longer than just cutting/pasting and running a complete regex for every tag. shame.

Replies are listed 'Best First'.
Re: Re: Re: Drop in regex replacements?
by Joost (Canon) on Sep 09, 2002 at 15:07 UTC
    Please read my above explanation for what I am doing here.

    I am changing the problem around to make it easier to maintain and expand. If you really need to have compact code, you can change the &replace sub like this:

    my %replaces = ( email => sub { "<a href=mailto:'$_[0]'>$_[1]</a>" }, url => sub { "<a href='$_[0]'>$_[1]</a>'" }, # etc etc etc ); sub replace { my ($tag,$attr,$content) = @_; $attr ||= $content; return $replaces{$tag}->($attr,$content); }
    I was merely trying to make the code as clean and clear as I could.
    -- Joost downtime n. The period during which a system is error-free and immune from user input.

Log In?

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

How do I use this? | Other CB clients
Other Users?
Others studying the Monastery: (5)
As of 2023-01-30 11:17 GMT
Find Nodes?
    Voting Booth?

    No recent polls found