Answer the question
In order to leave comments, you need to log in
How to convert a hashtag into a link?
I pull out the news from the contact using wall.get. I get the text of the news with hashtags. Hashtags come as plain text. With this function, I replace hashtags with links, but only English hashtags change. What regular expression is needed to select Cyrillic
function hashtag($text){
$pattern = "/\#(\w+)/";
$text= preg_replace($pattern, '<a href="http://vk.com/feed?q=%23$1§ion=search" target="_blank">#$1</a>',$text);
echo $text;
}
Answer the question
In order to leave comments, you need to log in
first try
to make your expression ignore case and work with multibyte characters
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question