Tutorials Point


  JavaScript Basics
  JavaScript Objects
  JavaScript Advanced
  JS Useful References
  JS Useful Resources
  Selected Reading

Copyright © 2014 by tutorialspoint



  Home     References     Discussion Forums     About TP  

Javascript RegExp - source Property


previous next AddThis Social Bookmark Button


Advertisements

Description:

source is a read-only string property of RegExp objects. It contains the text of the RegExp pattern. This text does not include the delimiting slashes used in regular-expression literals, and it does not include the "g", "i", and "m" attributes.

Syntax:

RegExpObject.source

Here is the detail of parameters:

  • NA

Return Value:

Returns the text used for pattern matching

Example:

<html>
<head>
<title>JavaScript RegExp source Property</title>
</head>
<body>
<script type="text/javascript">
   var str = "Javascript is an interesting scripting language";
   var re = new RegExp( "script", "g" );

   re.test(str);
   document.write("The regular expression is : " +  re.source); 
</script>
</body>
</html>

This will produce following result:

The regular expression is : script 

To understand it in better way you can Try it yourself.



previous next Printer Friendly

Advertisements


  

Advertisements