How to match a pound (#) symbol at the beginning of a word using regex in PHP [duplicate]

StackOverflow https://stackoverflow.com/questions/9422664

  •  12-11-2019
  •  | 
  •  

Вопрос

This question already has an answer here:

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.

Нет правильного решения

Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top