Skip to content

Instantly share code, notes, and snippets.

@ryosms
Created August 18, 2012 17:02
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ryosms/3388407 to your computer and use it in GitHub Desktop.
Save ryosms/3388407 to your computer and use it in GitHub Desktop.
count tweet's characters with twitter-text-java
public int countTweetCharacters(String text) {
int count = text.length();
Extractor extractor = new Extractor();
List<String> urls = extractor.extractURLs(text);
for (String url : urls) {
count -= (url.length() - 20);
if (url.startsWith("https://")) {
count += 1;
}
}
return count;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment