Regular Expressions 101

Community Patterns

Community Library Entry

1

Regular Expression
PCRE (PHP <7.3)

/
(@[\w\.]*)|(#\w[^#\W]+)
/
gi

Description

This regular expression can be used to find tags and hashtags in a string. It assumes that a username can contain both underscores and points (.) and that hashtags can only contain letters

Submitted by Luca Simonetti - 10 years ago