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



Reffered: https://www.geeksforgeeks.org


JavaScript

Related
JavaScript RegExp unicode Property JavaScript RegExp unicode Property
JavaScript RegExp source Property JavaScript RegExp source Property
JavaScript Atomics waitAsync() Method JavaScript Atomics waitAsync() Method
JavaScript RegExp sticky Property JavaScript RegExp sticky Property
JavaScript RegExp hasIndices Property JavaScript RegExp hasIndices Property

Type:
Geek
Category:
Coding
Sub Category:
Tutorial
Uploaded by:
Admin
Views:
12