Match on dollar sign. HELP
Posted: Thu May 13, 2010 4:04 pm
I'm looking to make a regex that gets a word that starts with a dollar sign and am having some trouble. Ex:
String : "Hello world. My name is $Michael";
I want the preg_replace to replace it with:
http://www.twitter.com/Michael/
Here is what I've tried
"\$([A-Za-z]\s)#ise", "'\\1<a href=\"http://www.twitter.com/\\1\" >\\1</a>'"
but something seems to be wrong or I'm going about this the wrong way. Could someone offer some advice on this?
Thanks
String : "Hello world. My name is $Michael";
I want the preg_replace to replace it with:
http://www.twitter.com/Michael/
Here is what I've tried
"\$([A-Za-z]\s)#ise", "'\\1<a href=\"http://www.twitter.com/\\1\" >\\1</a>'"
but something seems to be wrong or I'm going about this the wrong way. Could someone offer some advice on this?
Thanks