preg_replace matching @USERNAME

Hi

I’m trying to match @USERNAME in a string and replace it with @USERNAME

I’ve tried a few different methods:

preg_replace ('/@(.*?)/', '<a href="message.php?member=$1">$1</a>', $str)

and also [@] and @ but i just can’t seem to get it to work. any help would be appreciated!

Off the top of my head I’d say try adding a space to the end of your regexp
[php]<?php
$str =“testing @george_lopez again” ;
echo preg_replace (’@@(.*?)\s@is’, ‘@$1’, $str) ;
?>[/php]
Yes?

Sponsor our Newsletter | Privacy Policy | Terms of Service