Tutorial by Examples

Suppose we have a list of teams, named like this: Team A, Team B, ..., Team Z. Then: Team [AB]: This will match either either Team A or Team B Team [^AB]: This will match any team except Team A or Team B We often need to match characters that "belong" together in some context or ano...
Consider the character class [aeiou]. This character class can be used in a regular expression to match a set of similarly spelled words. b[aeiou]t matches: bat bet bit bot but It does not match: bout btt bt Character classes on their own match one and only one character at a time...
[^0-9a-zA-Z] This will match all characters that are neither numbers nor letters (alphanumerical characters). If the underscore character _ is also to be negated, the expression can be shortened to: [^\w] Or: \W In the following sentences: Hi, what's up? I can't wait for 2017!...
[^0-9] This will match all characters that are not ASCII digits. If Unicode digits are also to be negated, the following expression can be used, depending on your flavor/language settings: [^\d] This can be shortened to: \D You may need to enable Unicode character properties support expl...
1. Character Class Character class is denoted by []. Content inside a character class is treated as single character separately. e.g. suppose we use [12345] In the example above, it means match 1 or 2 or 3 or 4 or 5 . In simple words, it can be understood as or condition for single characters (...
POSIX character classes are predefined sequences for a certain set of characters. Character classDescription[:alpha:]Alphabetic characters[:alnum:]Alphabetic characters and digits[:digit:]Digits[:xdigit:]Hexadecimal digits[:blank:]Space and Tab[:cntrl:]Control characters[:graph:]Visible characters ...

Page 1 of 1