Add Searching Tools with Regular Expression Operators in JavaScript

The regular expression mechanism adds extremely powerful searching tools to your programming. Here are some of the most commonly used regular expressions as they are used in JavaScript.






























































































OperatorDescriptionSample patternmatchesDoesn’t match
. (period)Any single character except class="code">newline.E\n
^Beginning of string^aappleBanana
$End of stringa$bananaApple
[characters]Any of a list of characters in braces[abcABC]AD
[char range]Any character in the range[a-zA-Z]F9
\dAny single numerical digit\d\d\d-\d\d\d\d123-4567The-thing
\bA word boundary\bthe\btheTheater
+One or more occurrences of the previous character\d+1234Text
*Zero or more occurrences of the previous character[a-zA-Z]d*B17, g7
{digit}Repeat preceding character digit times\d{3}-\d{4}123-4567999-99-9999
{min, max}Repeat preceding character at least min but not more
than max times
.{2,4}Ca, com, infowatermelon
(pattern segment)Store results in pattern memory returned with code^(.).*\1$gig, wallowBobby



dummies

Source:http://www.dummies.com/how-to/content/add-searching-tools-with-regular-expression-operat.navId-405061.html

No comments:

Post a Comment