JavaScript RegExp source Property

The JavaScript source properrty is used to get the text/string of the Regular Expression pattern. For example:

HTML with JavaScript Code
<!DOCTYPE html>

   <p id="res"></p>

      let myString = "I live in St. Louis";
      let myPattern = /is/gi;
      document.getElementById("res").innerHTML = myPattern.source;

JavaScript source Syntax

The syntax of source property in JavaScript is:


It returns a string representing the textual part of the specified regular expression pattern.

JavaScript Online Test

« Previous Tutorial Next Tutorial »

Liked this article? Share it!

Like/follow us on social media for updates!