โ— Shell
clean mode source โ†—

JavaScript - RegExp source Property



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

Its syntax is as follows โˆ’

RegExpObject.source

Return Value

Returns the text used for pattern matching.

Example

Try the following example program.

<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>

Output

The regular expression is : script 

javascript_regexp_object.htm