RegExp Instance Properties

Description

RegExp type has the following properties:

  • global - A Boolean value tells if the g flag has been set.
  • ignoreCase - A Boolean value tells if the i flag has been set.
  • lastIndex - the character position where the next match will be attempted. This value begins as 0.
  • multiline - A Boolean value indicating whether the m flag has been set.
  • source - The string source of the regular expression without opening and closing slashes.

Example


var pattern1 = /\[bh\]at/i;
console.log(pattern1.global);     //false
console.log(pattern1.ignoreCase); //true
console.log(pattern1.multiline);  //false
console.log(pattern1.lastIndex);  //0
console.log(pattern1.source);     
/* www  .  j  a  v  a2 s  .  c  o m*/
var pattern2 = new RegExp("\\[bh\\]at", "i");

console.log(pattern2.global);     //false
console.log(pattern2.ignoreCase); //true
console.log(pattern2.multiline);  //false
console.log(pattern2.lastIndex);  //0
console.log(pattern2.source);     

The code above generates the following result.





















Home »
  Javascript »
    Javascript Introduction »




Script Element
Syntax
Data Type
Operator
Statement
Array
Primitive Wrapper Types
Function
Object-Oriented
Date
DOM
JSON
Regular Expressions