Defining Patterns : Introduction « Regular Expressions « JavaScript Tutorial

Home
JavaScript Tutorial
1.Language Basics
2.Operators
3.Statement
4.Development
5.Number Data Type
6.String
7.Function
8.Global
9.Math
10.Form
11.Array
12.Date
13.Dialogs
14.Document
15.Event
16.Location
17.Navigator
18.Screen
19.Window
20.History
21.HTML Tags
22.Style
23.DOM Node
24.Drag Drop
25.Object Oriented
26.Regular Expressions
27.XML
28.GUI Components
29.Dojo toolkit
30.jQuery
31.Animation
32.MS JScript
JavaScript Tutorial » Regular Expressions » Introduction 




There are special characters for creating almost any pattern.

Special Pattern Matching Characters

CharacterDescription
\wMatches any word character (alphanumeric).
\WMatches any non-word character.
\sMatches any whitespace character (tab, newline, carriage return, form feed, vertical tab).
\SMatches any non-whitespace character.
\dMatches any numerical digit.
\DMatches any character that is not a number.
[\b]Matches a backspace.
.Matches any character except a newline.
[...]Matches any one character within the brackets.
[^...]Matches any one character not within the brackets.
[x-y]Matches any character in the range of x to y.
[^x-y]Matches any character not in the range of x to y.
{x,y}Matches the previous item at least x times but not to exceed y times.
{x,}Matches the previous item at least x times.
{x}Matches the previous item exactly x times.
?Matches the previous item once or not at all.
+Matches the previous item at least once.
*Matches the previous item any number of times or not at all.
|Matches the expression to the left or the right of the | character.
(...)Group everything inside parentheses into a subpattern.
\xMatches the same characters that resulted from the subpattern in group number x. Groups, which are designated with parentheses, are numbered from left to right.
^Matches the beginning of the string or beginning of a line, in multiline matches.
$Matches the end of the string or end of a line, in multiline matches.
\bMatches the position between a word character and a non-word character.
\BMatches the position that is not between a word character and a non-word character.
















26.1.Introduction
26.1.1.Pattern Matching
26.1.2.Defining Patterns
26.1.3.All the characters that require a backslash character to be taken literally within a pattern.
26.1.4.Pattern Attributes
26.1.5.Testing for Pattern Matches
26.1.6.The pattern matching methods in the RegExp object require String objects.
java2s.com  | Contact Us | Privacy Policy
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.