标签:guava charmatcher java
1.CharMatcher的field 类型
ANY:匹配任意字符。
NONE:任何字符都不匹配
WHITESPACE:匹配字符里面的空格。
BREAKING_WHITESPACE:匹配字符之间是否被空格隔断。
INVISIBLE:确定字符是否不可见,不可见的字符包括:SPACE_SEPARATOR, LINE_SEPARATOR, PARAGRAPH_SEPARATOR,
CONTROL, FORMAT, SURROGATE, 和PRIVATE_USE
DIGIT: Determines whether a character is a digit according to Unicode. If you only care to match ASCII digits,
you can use inRange(‘0‘, ‘9‘).
JAVA_LETTER:Determines whether a character is a letter according to Java‘s definition. If you only care to
match letters of the Latin alphabet, you can use inRange(‘a‘, ‘z‘).or(inRange(‘A‘, ‘Z‘))。
JAVA_DIGIT:Determines whether a character is a digit according to Java‘s definition. If you only care to match
ASCII digits, you can use inRange(‘0‘, ‘9‘)。
JAVA_LETTER_OR_DIGIT :
Determines whether a character is a letter or digit according to Java‘s
definition.
JAVA_ISO_CONTROL :Determines whether a character is an ISO control character as specified
JAVA_LOWER_CASE:
Determines whether a character is lower case according to Java‘s
definition.
JAVA_UPPER_CASE :Determines whether a character is upper case according to Java‘s definition.
ASCII:Determines whether a character is ASCII, meaning that its code point is less than 128.
SINGLE_WIDTH:Determines whether a character is single-width (not double-width). When in doubt,
this matcher errs on the side of returning false (that is, it tends to assume a character is double-width).
2.CharMatcher的经常使用方法与实例
removeForm:aa
retainForm:aa
replaceFrom_1:afbcd
replaceFrom_2:aThreebcd
trimFrom:cat
trimLeadingFrom:catabb
trimTrailingFrom:abacat
collapseFrom:-ookk-p-
trimAndCollapseFrom:ookk-p
matchesAnyOf:false
or:59F
negate:ddcF
guava中String的CharMatcher,布布扣,bubuko.com
guava中String的CharMatcher
标签:guava charmatcher java
原文地址:http://blog.csdn.net/qunzer/article/details/25408255