\s- Matches where a string contains any whitespace character. Equivalent to[ \t\n\r\f\v]. \S- Matches where a string contains any non-whitespace character. Equivalent to[^ \t\n\r\f\v]. \w- Matches any alphanumeric character (digits and alphabets). Equivalent to[a-zA-Z0-9_]. By...
[[:alpha:]] ASCII character class ([A-Za-z]). [[:^alpha:]] Negated ASCII character class ([^A-Za-z]). [x[^xyz]] Nested/grouping character class (matching any character except y and z). [a-y&&xyz] Intersection (matching x or y). [0-9&&[^4]] Subtraction using intersection...
Regex:^\\p{Alnum}+$// Matches alphanumeric in any locale ^: Asserts the position at the start of the string. [a-zA-Z0-9]: Matches any alphanumeric character (i.e., lowercaseatoz, uppercaseAtoZ, and digits0to9). +: Matches one or more of the preceding tokens (i.e., one or m...
`a.b` will match any three-character string that starts with `a` and ends with `b`. `a+b` will match any string that starts with `a` and ends with `b`, and has one or more `a` characters in between. `a*b` will match any string that starts with `a` and ends with `b`,...
In regex, we can match any character using period "." character. To match only a given set of characters, we should use character classes.
Section 1\b\d{3}- This section begins with a word boundary to tell regex to match the alpha-numeric characters. It then matches 3 of any digit between 0-9 followed by either a hyphen, a period, or nothing[-.]?. Section 2\d{3}- The second section is quite similar to the first ...
\S - Matches where a string contains any non-whitespace character. Equivalent to [^ \t\n\r\f\v].ExpressionStringMatched? \S a b 2 matches (at a b) No match\w - Matches any alphanumeric character (digits and alphabets). Equivalent to [a-zA-Z0-9_]. By the way, underscore _ is...
means “any character, and as many of them as it takes to get to the next part of the regex. The second part\\means “a backslash”. Because\is the escape character, we’re basically escaping the escape character. The last part$is the signal for the end of the line. Effectively, ...
[Character set.Match any character in the set. A-ZRange.Matches a character in the range "A" to "Z" (char code 65 to 90). Case sensitive. ] ) \wWord.Matches any word character (alphanumeric & underscore). +Quantifier.Match 1 or more of the preceding token....
If theLOCALEflag is used, matches characters considered alphanumeric in the current locale and the underscore. \WMatches any character which is not a word character. This is the opposite of\w. If theASCIIflag is used this becomes the equivalent of[^a-zA-Z0-9_]. If theLOCALEflag is used...