Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Help with a regular expression ......

Status
Not open for further replies.

raze

IS-IT--Management
Jan 19, 2000
15
GB
Hi there. <br>
<br>
I'm trying to transform text strings into URLS, but only if they start with any character apart from a &quot; character.<br>
<br>
So far, I've tried ...<br>
<br>
(?:[^&quot;]¦)( ......<br>
<br>
Which I thought would match the http:// as long as there wasn't a quote in front of it. However, it still matches (not sure why to be honest)
 
This is what I came up with when trying to make a url into a link when I read an email.<br>
<br>
foreach $mail (@mailbody) # Now print each line<br>
{ <br>
<br>
$mail =~ s{<br>
(<br>
(?:ftp ¦ https?)<br>
:// <br>
\S+<br>
)<br>
}{<br>
my $url = $1;<br>
my ($junk) = $url =~ s!([^\w+&=/]*)$!!;<br>
$mail =&quot;&lt;a href=$url target=new&gt;$url&lt;/a&gt;&quot;;<br>
}xge;<br>
$mail =~ s/\r/&lt;br&gt;/;<br>
print &quot;$mail\n&quot;; <br>
} <p>Stanley<br><a href=mailto:webmaster@glass-images.com>webmaster@glass-images.com</a><br><a href= Images</a><br>
 
Here's a great link that might help- I found it in part of a series of decent tutorials. I've actually saved this document to my hard drive, and I've referred to it more than anything else.<br>
<br>
<A HREF=" TARGET="_new"><br>
There's no link back to the tutorial, so I thought I'd just throw that up there too.<br>
<A HREF=" TARGET="_new"><br>
Let me know if that helps... if not, let me know and I'll see what I can do for you. <p>Liam Morley<br><a href=mailto:lmorley@wpi.edu>lmorley@wpi.edu</a><br><a href= imotic ::</a><br>
 
Thanks ... :)<br>
<br>
I think I have a solution now ... and I'll get a book on regular expressions as soon as I can!<br>

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top