Include all emojis and some special characters in hashtag link using Regex in PHP

92 views Asked by At

I'm extracting usernames from a string starting with # sign and converting to a hashtag link. For this my code is

$str = "#John_Smith  #DanielCarter and #JackFoster are the good programmers";

$regex = "/#+([a-zA-Z0-9@_]+)/";

$string = preg_replace($regex, '<a href="user_page.php?userName=$1">$0</a>', $str);

Now the problem is that the hashtag link on emojis is stopping and not moving further, and I know the code below is used to track the emojis.

(\u00a9|\u00ae|[\u2000-\u3300]|\ud83c[\ud000-\udfff]|\ud83d[\ud000-\udfff]|\ud83e[\ud000-\udfff])

But I don't know how to use in this situation

0

There are 0 answers