Possible Duplicate:
Regex to conditionally replace Twitter hashtags with hyperlinks
I’m trying to get the word after the symbol #
so the following strings, should all return stack_overflow
#stack_overflow
hello #stack_overflow
blahblahblah#stack_overflow
What would the pattern look like?
\wmatches a “word” character, so:\wincludes lowercase and uppercase lettersatoz, digits, and the underscore. If you need more, use a character set.Then, if you put it in a group, you can capture it. Here’s a demo.