JavaScript Regex Dotall and Flags Properties

JavaScript regex provides two flag-related properties for validation. The object's "dotAll" and "flags" properties operate the flag with the regex pattern. The dotAll property shows the availability of the "s" flag with the regex. The flags property shows flags in reverse order.

JavaScript regex dotall property

The javascript regex "dotAll" property shows a Boolean value for the "s" flag's availability. If the "s" flag is available, the output is true; otherwise, the output is false.

Syntax

The following syntax is used to get the object prototype.

Description:

  • The dotAll shows the return value in Boolean format to get the availability of the "s" flag.

Examples

The following examples work for the dotAll property of regex and its value.

Example 1:

The example shows the regex format for the dotAll property. Here, we use regex directly with the availability.

Output

The output shows the true value of the object function.

JavaScript Regex Dotall and Flags Properties

Example 2:

The example shows the regex format for the dotAll property. Here, we use regex directly with the property keyword. The "s" flag is unavailable, so the output shows a false value.

Output

The output shows the false value of the object function.

JavaScript Regex Dotall and Flags Properties

Example 3:

The example shows the method of the regex pattern for the dotAll property. Here, we use the regex format with keywords to get output.

Output

The output shows the native code of the object function.

JavaScript Regex Dotall and Flags Properties

JavaScript Regex Flags Property

The flags used in the Regular Expression can be obtained using the accessor property known as JavaScript RegExp flags. A string concatenation occurs because the flags are returned in alphabetical order.

Syntax

The following syntax is used to get the object flag value.

Description:

  • The flags show the return value in flag format in the ascending value.
  • If the flag is unavailable and uses the "flags" keyword, the output shows empty or space.

Examples

The following examples work for the flags property of regex and its value.

Example 1:

The example shows the regex format for the flags property. Here, we use property with regex directly to get output alphabetically.

Output

The output shows the flag information in ascending order.

JavaScript Regex Dotall and Flags Properties

Example 2:

The example shows the flags property with the regex format. Here, we use property with regex directly to get alphabetically flagged data.

Output

The output shows the flag information in ascending order.

JavaScript Regex Dotall and Flags Properties

Example 3:

The example shows the method of the regex pattern for the flags property. We use the regex format and mi flag with keywords to get output.

Output

The output shows the flag information in ascending order.

JavaScript Regex Dotall and Flags Properties

Conclusion

The property gets the regex pattern with extra flags or modifiers.






Latest Courses