Organizational Research By

Surprising Reserch Topic

Experts Most Trusted Topic


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
17 views



Related Hot Questions



Government Jobs Opening


...