Regex - negative look-ahead assertion
I wand to replace URLs like www.example.com/profile/USERNAME by [user]USERNAME[/user] BBCode!
$userURLSearch = "#((https?|ftp)://|www\.)example\.com/profile/([A-Za-z][A-Za-z0-9_-]+)(?!/)#i";
$userURLReplace = "[user]\\3[/user]";
$text = preg_replace($userURLSearch, $userURLReplace, $text);
开发者_StackOverflow社区
But it also transforms URLs like www.example.com/profile/USERNAME/more/and/more into [user]USERNAME[/user]/more/and/more ... :( It should only transform exactly "/profile/USERNAME".
can somebody help me? thx
Replace (?!/) by $ at the end?
精彩评论