10.07.2017 Views

javascript_tutorial

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

Javascript<br />

Try the following example program.<br />

<br />

<br />

JavaScript RegExp source Property<br />

<br />

<br />

<br />

var str = "Javascript is an interesting scripting language";<br />

var re = new RegExp( "script", "g" );<br />

re.test(str);<br />

document.write("The regular expression is : " + re.source);<br />

<br />

<br />

<br />

Output<br />

The regular expression is : script<br />

RegExp Methods<br />

Here is a list of the methods associated with RegExp along with their description.<br />

Method<br />

Description<br />

exec()<br />

test()<br />

toSource()<br />

toString()<br />

Executes a search for a match in its string parameter.<br />

Tests for a match in its string parameter.<br />

Returns an object literal representing the specified<br />

object; you can use this value to create a new object.<br />

Returns a string representing the specified object.<br />

In the following sections, we will have a few examples to demonstrate the usage<br />

of RegExp methods.<br />

319

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!