RegExp Instance Properties
In this chapter you will learn:
RegExp Instance Properties
Each instance of RegExp has the following properties:
Property | Meaning | Type |
---|---|---|
global | whether the g flag has been set. | Boolean |
ignoreCase | whether the i flag has been set. | Boolean |
lastIndex | the character position where the next match. This value begins as 0. | integer |
multiline | whether the m flag has been set. | Boolean |
source | the 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>
Next chapter...
What you will learn in the next chapter:
Home » Javascript Tutorial » Regular Expressions