Thursday, September 4, 2025
HomeLanguagesJavascriptJavaScript source Property

JavaScript source Property

The source Property in JavaScript is used to return the text of the RegExp pattern.

Syntax: 

RegExpObject.source

Where RexExp refers to the regular expression.

Example : This example returns the text “Geek”. 

html




<script>
    function geek() {
        var patt1 = /Geek/gi;
        var res="Text of RegExp is: " + "<b>" + patt1.source + "</b>";
        document.getElementById("app").innerHTML = res ;
    }
</script>
  
<h1 style="color:green">neveropen</h1>
<h2>Source Property</h2>
<p>RegExp: /Geek/gi</p>
<button onclick=geek()>Click it!</button>
<p id="app"></p>


Output:

JavaScript source Property

JavaScript source Property

 

Supported Browsers: The browsers supported by JavaScript source Property are listed below:

  • Google Chrome
  • Apple Safari
  • Mozilla Firefox
  • Opera
  • Internet Explorer
RELATED ARTICLES

Most Popular

Dominic
32264 POSTS0 COMMENTS
Milvus
81 POSTS0 COMMENTS
Nango Kala
6629 POSTS0 COMMENTS
Nicole Veronica
11799 POSTS0 COMMENTS
Nokonwaba Nkukhwana
11859 POSTS0 COMMENTS
Shaida Kate Naidoo
6749 POSTS0 COMMENTS
Ted Musemwa
7025 POSTS0 COMMENTS
Thapelo Manthata
6698 POSTS0 COMMENTS
Umr Jansen
6717 POSTS0 COMMENTS