Open In App

JavaScript RegExp unicode Property

Last Updated : 01 Aug, 2023
Improve
Improve
Like Article
Like
Save
Share
Report

JavaScript RegExp unicode property is used to check whether the ‘u’ flag is set or not in the Regular Expressions flag. If the ‘u’ flag is set then this property returns true else false.

Syntax:

Regexpobj.unicode

Return Type: A boolean value.

Example 1: This example checks whether ‘u’ flag is present or not and prints it on the console.

Javascript




function unicodeProp() {
    let regex = new RegExp(/[a-d]/, 'u');
 
    console.log(regex.unicode);
}
 
unicodeProp();


Output

true

Example 2: This example checks whether ‘u’ flag is present or not.

Javascript




function unicodeProp() {
    let regex = new RegExp(/[a-d]/, 'y');
 
    if (regex.unicode) {
        console.log("u flag is present");
    } else {
        console.log("u flag is absent");
    }
}
 
unicodeProp();


Output

u flag is absent

Supported Browsers:

  • Chrome 50
  • Edge 12
  • Firefox 46
  • Opera 37
  • Safari 10

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


Like Article
Suggest improvement
Previous
Next
Share your thoughts in the comments

Similar Reads