JavaScript RegExp [^0-9] Groups (not for number)

Javascript regex groups are used for numbers not available as a character in the string. Using the regex method, we can set the range of the numbers or single numbers to get the required character. The test, search, and match method has no sign and specific numbers for the characters in the brackets, such as [^9]. We can use a group of the numbers such as [^0-9].

Syntax

The following syntax is used to regex groups for unavailable numbers.

Or

Description :

  • Using the regex group, we can use a global modifier to unavailable required numbers.
  • We can use the regex group with or without a modifier.

Examples

The following examples show the regex group [^0-9] or [^0] for the not number available in the string.

Example 1

The following example works for a simple number (^8) using a regex group. Here, we use a single number with a global modifier.

Output

The Output shows 8 numbers unavailable in the bracket for the string.

JavaScript RegExp [^0-9] Groups (not for number)

Example 2

The following example shows unavailability for simple number group [^0-5] using javascript regex. Here, we use the number between zero and five with the modifier for numerical value.

Output

The Output shows [0-5] number unavailable in the bracket for the string.

JavaScript RegExp [^0-9] Groups (not for number)

Example 3

The following example matches the range of the number not available in the string using [^0-5].

Output

The Output shows [0-5] number unavailable in the bracket for the string.

JavaScript RegExp [^0-9] Groups (not for number)

Example 4

The following example searches the required set of numbers to get the position of the number. The search method shows the availability of the number of the group.

Output

The Output shows the unavailability of the number.

JavaScript RegExp [^0-9] Groups (not for number)

Example 5

The following example shows a given group's value's unavailability. The match method is used for the group of the number (^123) for the string. The regex fetches the input string's 1, 2, and 3 numbers.

Output

The output shows a group of the numbers in a string.

JavaScript RegExp [^0-9] Groups (not for number)

Conclusion

The regex for number groups is used to validate the numerical value using the bracket with number [0-9].






Latest Courses