I am trying to scan for hashtags from NSStrings in Objective-C and I am using regex. I made a test status on Facebook to see what are the valid hashtags as it is where I want to pattern my hashtag detection with. My problem is that my regex is still getting hashtags that are not preceded by a space or comes before an alphanumeric. In somethin#idfsjoa
the #idfsjoa
is being detected as a hashtag when it shouldn't be. I am using regexpal to test my regex.
How do I check if the "#" does not come after a space"?
From Facebook:
The NSString:
#face #Fa!ce something #iam#1 #1 #919 #jifdosaj somethin#idfsjoa #9#9#98 9#9f9j#9jlasdjl #jklfdsajl34 #34239 #jkf #a #1j3rj3
The regular expression I currently have:
(?!\w+)#(\w+)([A-Za-z0]+)