Racoon Racoon - 1 year ago 37
PHP Question

Find Regex word

What is regular expression to find tag like this:

Here is text and there is tag @username can be spaces here (#12345678) and this is end!

I need to find by:

  • Tag starts with "@"

  • Then somewhere will be "(#"

  • And always after 8 symbols from # will be ")"

So, important match parts are: @ (#********)


Language is PHP


@Martin's Van Der Buren (#6575GT67)

Not valid:

@Martin's Van Der Buren #6575GT67)

@Martin's Van Der Buren (6575GT67)

@Martin's Van Der Buren (#6575GT67

Answer Source

You can use:


This will match an @ followed by any number of characters then the pattern (#12345678)