Hi there -- I am currently involved in trying to do two things:

1) take input text (in the form of a string parameter value to a script) of potentially email and web addresses and replace them with clickable alternatives.

i.e.
www.domain.com to be replaced/rewritten as <a href="/cgi-bin/script.pl?u=www.domain.com">www.domain.com</a> and mail@domain.com to be rewritten as <a href="mailto:mail@domain.com">mail@domain.com</a>

To to do the above I am working using both Email::Find and URI::Find although I have been using the s!(www.[^\s]+)!<a href="/cgi-bin/script.pl?u=$1">$1</a>!gi piece of code up to now for web addresses.

----....
Now the bit that is causing a bit of a headache is doing it the other way round.

i.e. converting the clickable links as shown above back to their text original. Do I need a wierd and wonderful regex and substitition piece of code or is there a module that will make my life easy? I need to be able to reproduce my html link format and not just have a simple target=_blank href?

Any ideas?


In reply to replacing clickable web and email addresses by markolus

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.