views:

278

answers:

3
+2  A: 

Isn't it ironic, as soon as I post this I find an answer. So if you are looking for a matching pattern to do this, the following seems to work:

(?:\s|\A)[##]+([A-Za-z0-9-_]+)

I am going to do a lot more testing with this to see if there are any edge cases that are outside the scope of this expression and will report back if I find any.

Daniel Dura
A: 

I think this

(\s|\A)#(\w+)

works as well and is a little more precise. BTW, when working with Java regular expressions I always use regexplanet to test my expressions. Much faster than testing in Java.

--Hardy

Hardy
A: 

@Daniel Dura: [##] this is supposed to be pointless. The brackets [] are used to denote character classes. [##] is same as [#]. And [##]+ is same as [#]+ .

vulcan_hacker