how to use Character classes in regular exp?

Rather than name only a single character, you can include a pattern in a regular expression that matches any of a set of characters.

A set of characters can be given as a simple list inside square brackets, e.g. /[aeiou]/ will match any single lowercase vowel. For letter or number ranges you may also use only the first and last letter of a range, with a dash in the middle, e.g. /[A-Ma-m]/ will match any lowercase or uppercase in the first half of the alphabet.

Many regular expression tools also provide escape-style shortcuts to the most commonly used character class, such as \s for a whitespace character and \d for a digit. You could always define these character classes with square brackets, but the shortcuts can make regular expressions more compact and more readable.

asked Sep 13, 2013 in Regular-exp by rajesh
edited Sep 12, 2013
0 votes

1 Answer

0 votes



Google had a little lamb.
And everywhere that Google
went, the lamb was sure
to go.
answered Sep 13, 2013 by rajesh
edited Sep 12, 2013