Solved

fun with expressions and metacharacters

Posted on 1998-08-30
6
180 Views
Last Modified: 2010-03-05
I need to do a couple of things.  First I need to get all the * 's out of a variable and also any -- , i just need to git rid of them, not replace them.  And also the more difficult of the two i believe, i have a varibable, say, $post, i need to check to see if it has www. something, i need to change that into <a href=www.whatever>www.whatever</a> cause on a chat i need to allow them to show links, html code is normally stripped. So the $post shold remain the same except change www. into <a href.. etc.  Thanks for the help in advance.  Any questions just post.
0
Comment
Question by:idadan
  • 4
  • 2
6 Comments
 

Author Comment

by:idadan
ID: 1204611
Edited text of question
0
 
LVL 84

Expert Comment

by:ozo
ID: 1204612
$variable =~ tr/-*//d;

$post =~ s/(\bwww\.\S+)/<a href=$1>$1</a>/gi;
0
 

Author Comment

by:idadan
ID: 1204613
Talk about your quick 50, thanks so much, exactly what i was looking for.  btw, you forgot a \ before /a on the second one.. it's late, i understand, hehe.  Thanks again.
0
Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 

Author Comment

by:idadan
ID: 1204614
Ok Ozo last change you want your 50?....
0
 
LVL 84

Accepted Solution

by:
ozo earned 50 total points
ID: 1204615
$variable =~ tr/-*//d;

$post =~ s|(\bwww\.\S+)|<a href=$1>$1</a>|gi;

#You didn't say how to tell the end of "whatever"
#the above code assumes it ends with a blank character
0
 

Author Comment

by:idadan
ID: 1204616
Thanks for the help, great as always.
0

Featured Post

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Email validation in proper way is  very important validation required in any web pages. This code is self explainable except that Regular Expression which I used for pattern matching. I originally published as a thread on my website : http://www…
In the distant past (last year) I hacked together a little toy that would allow a couple of Manager types to query, preview, and extract data from a number of MongoDB instances, to their tool of choice: Excel (http://dilbert.com/strips/comic/2007-08…
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…

839 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question