RegExp Instance Properties

In this chapter you will learn:

  1. RegExp Instance Properties

RegExp Instance Properties

Each instance of RegExp has the following properties:

PropertyMeaningType
globalwhether the g flag has been set.Boolean
ignoreCasewhether the i flag has been set.Boolean
lastIndexthe character position where the next match. This value begins as 0.integer
multilinewhether the m flag has been set.Boolean
sourcethe regular expression.string

The following code shows how to use RegExp Instance Properties.

<!DOCTYPE html><!--from  j  a v a 2s .  c  o  m-->
<html>
<head>
    <script type="text/javascript">
        var pattern1 = /\[oo\]at/i; 
        
        document.writeln(pattern1.global); //false 
        document.writeln(pattern1.ignoreCase); //true 
        document.writeln(pattern1.multiline); //false 
        document.writeln(pattern1.lastIndex); //0 
        document.writeln(pattern1.source); //"\[oo\]at" 
        
    </script>
</head>
<body>
</body>
</html>

Click to view the demo

Next chapter...

What you will learn in the next chapter:

  1. How to use RegExp's exec() method to do the matching.
  2. How to deal with multiple matches
  3. Match with g
Home » Javascript Tutorial » Regular Expressions
Regexp Type
RegExp constructor
RegExp Instance Properties
RegExp's exec()
RegExp.test
RegExp's toLocaleString() and toString()