×
INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Help with a regular expression ......

Help with a regular expression ......

Help with a regular expression ......

(OP)
Hi there.

I'm trying to transform text strings into URLS, but only if they start with any character apart from a " character.

So far, I've tried ...

(?:[^"]¦)(http://¦) ......

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)

RE: Help with a regular expression ......

This is what I came up with when trying to make a url into a link when I read an email.

foreach $mail (@mailbody) # Now print each line
{

$mail =~ s{
(
(?:ftp ¦ https?)
://
\S+
)
}{
my $url = $1;
my ($junk) = $url =~ s!([^\w+&=/]*)$!!;
$mail ="<a href=$url target=new>$url</a>";
}xge;
$mail =~ s/\r/<br>/;
print "$mail\n";
}

Stanley
webmaster@glass-images.com
Glass Images

RE: Help with a regular expression ......

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.

http://wdvl.com/Authoring/Languages/Perl/PerlfortheWeb/perlintro2_table1.html

There's no link back to the tutorial, so I thought I'd just throw that up there too.
http://wdvl.com/Authoring/Languages/Perl/PerlfortheWeb/pattern_matching.html

Let me know if that helps... if not, let me know and I'll see what I can do for you.

Liam Morley
lmorley@wpi.edu
:: imotic ::

RE: Help with a regular expression ......

(OP)
Thanks ... :-)

I think I have a solution now ... and I'll get a book on regular expressions as soon as I can!

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members! Already a Member? Login

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close