JavaScript Regex ^ Quantifier

JavaScript regular expression uses the "^" quantifier to contain input characters at the start of the string. The ^ quantifier filters the value at the beginning of input information using methods. The modifier operates with the regexp method and quantifier to operate, replace, search, and match data.

Syntax

The following syntax uses the regex "^" quantifier to get unavailable characters.

Or

Or

Description

  • The global, multiline, and case-insensitive modifiers work with the starting character quantifier.
  • The "value" represents the input character at the string's start.

Supported browsers

The given browsers operate for the javascript regular expression's "^" quantifier.

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

Examples

The examples work with different methods, values, and modifiers using the regular expression of the "^" quantifier in JavaScript.

Example1

The example uses the match() method with the different values for the regex quantifier. The first value shows null output, and the second value shows the available value at the start of the string.

Output

The output shows the available characters at the start of the string.

JavaScript Regex ^ Quantifier

Example 2

The example uses the match() method with the global and case-insensitive modifier for the regex quantifier. We can see the difference between the two modifiers with the string.

Output

The output shows the available characters at the start of the string.

JavaScript Regex ^ Quantifier

Example 3

The example uses the quantifier and search() method with the various values for the regex quantifier. The first value shows "-1" output, and the second value shows the position of the characters.

Output

The output shows the available position start of the input string.

JavaScript Regex ^ Quantifier

Example 4

The example uses the quantifier and test() method with the various values for the regex quantifier. The first value shows "false" output, and the second regular expression shows "true" output.

Output

The output shows the Boolean value of the beginning input string.

JavaScript Regex ^ Quantifier

Example 5

The example uses the quantifier and replace() method with the replaced value for the regex quantifier. We can replace or remove values with a given pattern and new keyword for regular expression.

Output

The output shows the replaced value of the start characters.

JavaScript Regex ^ Quantifier

Conclusion

The JavaScript "^" quantifier works with a modifier to get the first input character using regular expression.






Latest Courses