I need a regex to match a word that starts with #.
I wrote this question How to match a pound (#) symbol in a regex in php (for hashtags), but I forgot to explain that I need the # at the beginning of a word.
I need to match #word, #123, #12_sdas, but not 1#234 or #1234.
For example, in "#match1 notMatch not#Match #match2 notMatch #match3", only #match1, #match2 and #match3 should appear.
Edit: I just want one pound (#), followed by one or more [a-ZA-Z0-9_]. The match can’t have any of [a-ZA-Z0-9_] before.
My problem was finding the pound at the beginning of the word.
Try this:
It will match all words beginning with a
#symbol. Words can be sepearted by all valid whitespace characters (so one of\t\r\n\v\f)Example