Chapter 5
Regular Expression, Rollover and Frames
,What is Regular Expression?
• A regular expression is very similar to a mathematical
expression, except a regular expression tells the browser how
to manipulate text rather than numbers by using special
symbols as operators.
• A regular expression is a sequence of characters that forms a
search pattern.
• When you search for data in a text, you can use this search
pattern to describe what you are searching for.
• A regular expression can be a single character, or a more
complicated pattern.
• Regular expressions can be used to perform all types of text
search and text replace operation
,Syntax:
• A regular expression could be defined with the RegExp
() constructor, as follows −
• var pattern = new RegExp(pattern, attributes);
or simply
• var pattern = /pattern/attributes;
Where
• pattern − A string that specifies the pattern of the
regular expression or another regular expression.
• attributes − An optional string containing any of the
"g", "i", and "m" attributes that specify global, case-
insensitive, and multi-line matches, respectively.
, Reg. Exp. Cont. :
Ex:
• var patt = /kkwp/i;
/kkwp/i is a regular expression.
• kkwp is a pattern (to be used in a search).
• i is a attribute (modifies the search to be case-
insensitive).
Regular Expression, Rollover and Frames
,What is Regular Expression?
• A regular expression is very similar to a mathematical
expression, except a regular expression tells the browser how
to manipulate text rather than numbers by using special
symbols as operators.
• A regular expression is a sequence of characters that forms a
search pattern.
• When you search for data in a text, you can use this search
pattern to describe what you are searching for.
• A regular expression can be a single character, or a more
complicated pattern.
• Regular expressions can be used to perform all types of text
search and text replace operation
,Syntax:
• A regular expression could be defined with the RegExp
() constructor, as follows −
• var pattern = new RegExp(pattern, attributes);
or simply
• var pattern = /pattern/attributes;
Where
• pattern − A string that specifies the pattern of the
regular expression or another regular expression.
• attributes − An optional string containing any of the
"g", "i", and "m" attributes that specify global, case-
insensitive, and multi-line matches, respectively.
, Reg. Exp. Cont. :
Ex:
• var patt = /kkwp/i;
/kkwp/i is a regular expression.
• kkwp is a pattern (to be used in a search).
• i is a attribute (modifies the search to be case-
insensitive).