I have some string with hashtags looks like @user_name. Now i convert all hashtags to links this way:
$text = preg_replace ("/@(\\w+)/", '<a href="http://$1.'.SITE_NAME.'">@$1</a> ', $text);
As you can see, all hashtags becomes to subdomain names. If you know, there some problems with _
symbol in subdomain names (some browsers not supports that, IE supports, but not set cookies, etc..). So i need to replace the _
symbols in subdomain to -
(minus), but keep _
symbols in hashtag view. There link what i need to <a href="http://user-name.site.com">@user_name</a>
. How?