currently I need to find some special lexical characteristics of a string in Java such as
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.