1.

What Are Regular Expressions And Regexp Object?

Answer»

A regular expression is an OBJECT that describes a PATTERN of characters.

The JavaScript RegExp class represents regular expressions, and both String and RegExp define methods that use regular expressions to perform powerful pattern-matching and search-and-replace FUNCTIONS on TEXT.

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;

Here is the description of the parameters:

  • 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 multiline matches, respectively.

A regular expression is an object that describes a pattern of characters.

The JavaScript RegExp class represents regular expressions, and both String and RegExp define methods that use regular expressions to perform powerful pattern-matching and search-and-replace functions on text.

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;

Here is the description of the parameters:



Discussion

No Comment Found