Javascript RegExp reference

Javascript build-in RegExp object reference.

Create regexp:

When the RegExp object is used as a function the return will be an expession object as well.

exp:

A string that represents the search for a match. ( In this string all \ (backslash) must be
types with \\ (double backslash).

flag:

An optional string for global search (g), case-insensitive search (i) and multiline mode search (m).
You can combine any of these characters.

An example of using the new Object(param):

<script type="text/javascript">
var str =["We are learning javascript","I like both java and javascript",
"Java is not the same as Javascript"];
// using new to create the objectvar pattern= new RegExp("\\bjava(\\b|\\B)","gi");
for( var word in str) {
// Match all Java word where the following char.= sdocument.write(str[word].replace(pattern,"[JAVA]")+ "<br>");
}
// Used as function
pattern= RegExp("\\bjava(\\b|\\B)","gi");
for( var word in str) {
// Match all Java word where the following char.= sdocument.write(str[word].replace(pattern,"[JAVA]")+ "<br>");
}
</script>

General information about the object member types:

Prototype created methods, properties or constants can only be used
on instances of an object or on a primitive datatype.

Constructor created methods, properties or constants can NOT be used
on instances of an object or on a primitive datatype.