[thelist] Search and replace

Dean Mah dmah at shaw.ca
Fri Sep 28 08:15:30 CDT 2001


In Perl, why not try something like:

   $textstring = "mailto:blah at balh.com?subject=moreblah";
   ($email) = ($textstring =~ /mailto:(.+)\?.+/);

You should be okay as long as their isn't more than one question mark
in your URI.

Dean


Adrian Fischer writes:

> I need to extract email addresses from a mailto links
> mailto:blah at balh.com?subject=moreblah
> in perl I need to match the mailto: and replace it with nothing and the same
> with ?subject.......
> If I can I need to make it generic enough to recognize that there may be no
> subject line and process just the mailto bit.
> So Im thinking that maybe if I can find the ? in the string the I can delete
> all after.
> I think I can adapt what I have learnt from some previous posts toget rid of
> the mailto. Hows this:
> $textstring="mailto:blah at balh.com?subject=moreblah"
> $textstring=^(.{7,80})/;




More information about the thelist mailing list