Sunday, November 17, 2024
Google search engine
HomeLanguagesJavascriptJavaScript RegExp flags Property

JavaScript RegExp flags Property

JavaScript RegExp flags property is an accessor property that returns the flags being used in the Regular Expression. The flags are returned in alphabetical order and the result is a concatenation of strings.

Syntax:

Regexobj.flags

Return Type: A string containing flags used in Regular Expression.

Example 1: This example prints the flags used in Regular Expression on the console.

Javascript




function flags_prop() {
    let regex = new RegExp(/[a-d]/, 'sm');
    console.log(regex.flags)
}
 
flags_prop();


Output

ms

Example 2: This example prints the flags used in Regular Expression.

Javascript




function flags_prop() {
    let regex =new RegExp(/[a-d]/, "sd");
     
    console.log("The flags are: " + regex.flags);
}
 
flags_prop();


Output

The flags are: ds

Supported Browsers:

  • Chrome 49
  • Edge 79
  • Firefox 37
  • Opera 39
  • Safari 9

We have a complete list of JavaScript RegExp expressions, to check those please go through this JavaScript RegExp Reference article.

Whether you’re preparing for your first job interview or aiming to upskill in this ever-evolving tech landscape, neveropen Courses are your key to success. We provide top-quality content at affordable prices, all geared towards accelerating your growth in a time-bound manner. Join the millions we’ve already empowered, and we’re here to do the same for you. Don’t miss out – check it out now!

RELATED ARTICLES

Most Popular

Recent Comments