sexyhilt.blogg.se

Java regex predefined character classes
Java regex predefined character classes








String pattern = input = "A city Albany Zulu maritime Marseilles" įoreach (Match match in Regex.Matches(input, pattern)) It uses the subexpression to represent the range of capital letters from A to Z. The following example matches words that begin with any capital letter. Match either a white-space character or a punctuation mark. Match one or more non-white-space characters, but as few as possible. Match the literal character "y" followed by a white-space character. For more information, see Character Class Subtraction.Ĭharacter classes that match characters by category, such as \w to match word characters or \p] is defined as follows: Pattern NET supports character class subtraction expressions, which enables you to define a set of characters as the result of excluding one character class from another character class. For more information, see Decimal Digit Character. A character in the input string can be anything other than a Unicode decimal digit. For more information, see Decimal Digit Character.Ī non-decimal digit. A character in the input string can be any of a number of characters classified as Unicode decimal digits. For more information, see Non-White-Space Character.Ī decimal digit. A character in the input string can be any character that is not a white-space character. For more information, see White-Space Character.Ī non-white-space character. A character in the input string can be any Unicode separator character, as well as any one of a number of control characters. For more information, see Non-Word Character.Ī white-space character. A character in the input string can belong to any Unicode category that is not a word character.

java regex predefined character classes

For more information, see Word Character.Ī non-word character. A character in the input string can belong to any of the Unicode categories that are appropriate for characters in words. For more information, see Negative Unicode Category or Unicode Block.Ī word character. A character in the input string must not be a member of a particular Unicode category or must not fall within a contiguous range of Unicode characters for a match to succeed. For more information, see Unicode Category or Unicode Block.Ī negative general Unicode category or named block. A character in the input string must be a member of a particular Unicode category or must fall within a contiguous range of Unicode characters for a match to succeed. For more information, see Any Character.Ī general Unicode category or named block. (dot or period) character in a regular expression is a wildcard character that matches any character except \n. For more information, see Negative Character Group.Īny character. A character in the input string must not match one of a specified set of characters. For more information, see Positive Character Group. A character in the input string must match one of a specified set of characters. NET supports the following character classes: Can only be used in a bracket expression.A character class defines a set of characters, any one of which can occur in an input string for a match to succeed.

java regex predefined character classes

Can only be used in a bracket expression.

java regex predefined character classes

Matches one character from a POSIX character class. matches one of 0 through 9 or a through z Reduces the character class to the characters present in both “base” and “intersect”. ] matches a single letter that is not a vowel. Removes all characters in the “subtract” class from the “base” class. ef ] is the same as and matches any letter between a and f. ef] matches aef], bef],, cef], and def]Īn opening square bracket inside a character class begins a nested character class. matches x (any character except a, b, c or d)Īn opening square bracket is a literal character that adds an opening square bracket to the character class. Negates the character class, causing it to match a single character not listed in the character class. ^ (caret) immediately after the opening [ (hyphen) between two tokens that each specify a single character.Īdds a range of characters to the character class. Unless otherwise noted, the syntax on this page is only valid inside character classes, while the syntax on all other reference pages is not valid inside character classes.Īll characters except the listed special characters are literal characters that add themselves to the character class.Ī backslash escapes special characters to suppress their special meaning.Ī backslash is a literal character that adds a backslash to the character class. Inside a character class, different rules apply. When used outside a character class, [ begins a character class.

java regex predefined character classes

Regular Expression Reference: Character Classes










Java regex predefined character classes