Java Regex - Extract hashtags from a string

You must extract the hashtag strings from the original string in Java. Any ideas / examples?

Thank you Sri

+5
java regex twitter
source share
1 answer

Here is what I use (it also processes UTF-8 tags, not just ASCII):

private static final Pattern TAG_PATTERN = Pattern.compile("(?:^|\\s|[\\p{Punct}&&[^/]])(#[\\p{L}0-9-_]+)"); 

Btw, you should be able to get hashtags from tweets ( include_entities=true )

+9
source share

All Articles