Skip to content

Conversation

@techinpark2
Copy link

I am trying to scan for hashtags from NSStrings in Objective-C and I am using regex.
I made a test status on Facebook / Instagram to see what are the valid hashtags as it is where

Now KILabel.m (getRangeForHashTags line : 437)

regex = [[NSRegularExpression alloc] initWithPattern:@"(?<!\w)#([\w_]+)?" options:0 error:&error];
My Solution (It's works fine. when not space)

regex = [[NSRegularExpression alloc] initWithPattern:@"((#)([\w_]+)?)" options:0 error:&error];
Thanks.

I am trying to scan for hashtags from NSStrings in Objective-C and I am using regex.
I made a test status on Facebook / Instagram to see what are the valid hashtags as it is where

Now KILabel.m (getRangeForHashTags line : 437)

regex = [[NSRegularExpression alloc] initWithPattern:@"(?<!\\w)#([\\w\\_]+)?" options:0 error:&error];
My Solution (It's works fine. when not space)

regex = [[NSRegularExpression alloc] initWithPattern:@"((#)([\\w\\_]+)?)" options:0 error:&error];
Thanks.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant