JavaScript RegExp {x,y} Quantifier

The {X, Y} quantifier contains and matches numbers from the x to y range. The regex quantifier operates in a string of numbers with the regular expression's search, match, test, and exec method. We can use regex modifiers for the available character with the quantifier.

Syntax

To get available characters, the following syntax uses a regular expression {x,y} quantifier.

Or

Description

  • The "a" is represented as an input character with the modifier.
  • The "x" shows the minimum numbers of the sequence input string.
  • The "y" shows the range of the maximum numbers of the sequence input string.
  • The global and case-insensitive modifiers work with the regex quantifier.

Supported Browsers

The given browsers support the javascript regex {x,y} quantifier.

  • Google Chrome
  • Internet Explorer
  • Opera
  • Safari
  • Firefox
  • Edge

Examples

The following examples use the {x,y} quantifier of the javascript regex. We can use numbers as characters in the quantifier.

Example1:

The given example shows the value range for the "j" character in the string. We can see the available range values of the input data.

Output

The output shows the value for the range of the quantifier.

JavaScript RegExp {x,y} Quantifier

Example2:

The given example shows the available range values of the input data using the match method.

Output

The output shows the value for the range of the quantifier.

JavaScript RegExp {x,y} Quantifier

Example 3:

The given example shows the range value's availability for the string's numerical values. We can see the available range values of the input data using the test method.

Output

The output shows the test value for the range of the quantifier.

JavaScript RegExp {x,y} Quantifier

Example 4:

The given example shows the range value for the numerical values in the string and replaces the required data.

Output

The output shows the replace value for the range of the quantifier.

JavaScript RegExp {x,y} Quantifier

Example 5:

The given example shows the index position of the value in the string.

Output

The output shows the position of the range of the quantifier.

JavaScript RegExp {x,y} Quantifier

Conclusion

The "x,y" quantifier sets the range from minimum and maximum value with the regular expression in javascript.






Latest Courses