15-03-2012, 04:04 PM
JavaScript Regular Expressions
[attachment=18396]
Definitions
String - Any collection of 0 or more characters.
Example:
“This is a String”
SubString - A segment of a String
Example:
“is a”
Case Sensitivity - detection if a character is upper or lower case.
What is a Regular Expression
A regular expression is a pattern of characters.
We use regular expressions to search for matches on particular text.
How are regular expressions implemented in JavaScript??
There are two ways:
1) Using literal syntax.
var RegularExpression = /pattern/
2) When you need to dynamically construct the regular expression, by creating instances of the regular expression object, RegExp.
var RegularExpression = new RegExp("pattern");
Categories of pattern matching characters
Position matching
Character classes matching
Repetition matching
Alternation and grouping matching
Back reference matching