I’m looking for a regex that will recognize # followed by a number in a string and make it clickable. Only if its # and a number like ex: #758 and make i clickable. Not # 758. Youtube has this for example.
Would really appreciate if someone could give me some hints since im worthless on regex.
Try this:
The regex is basically
/#\d+/, so the#character followed by one or more digits.preg_replaceis to replace such occurences with<a href="$0">$0</a>where$0is replaced by the match that has been found.And if you just need the number, use
/#(\d+)/and<a href="$1">$1</a>instead.