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(); |
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(); |
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.
