Search code examples
javalexical

Library for identifying lexical features of a string in Java


currently I need to find some special lexical characteristics of a string in Java such as

  • Total number of characters
  • Total number of alphabetic characters
  • Total number of uppercase characters
  • .... I wonder that is there a library can do that? It would be great to save coding time.
    Thank you very much.

Solution

  • google guava can do that.

    Have a look at the Strings module: http://code.google.com/p/guava-libraries/wiki/StringsExplained

    Check out the CharMatcher on that site!

    And after matching it, you just use the length() method of the remaining String.