JavaScript RegExp Group [^0-9]

Definition and Usage

The expression [^0-9] is used to find any character that is not a number.

The numbers inside the parentheses can be any number from 0 to 9 or a range of numbers.

Tip:Please use [0-9] Expression to find any number character between parentheses.

Example

Example 1

Global search for numbers not between 1 and 4:

let text = "123456789";
let pattern = /[^1-4]/g;

Try it yourself

Example 2

Global search for numbers not equal to 1:

let test = "12121212";
let pattern = /[^1]/g;

Try it yourself

Example 3

Global search for numbers not between 5 and 8:

let text = "123456789";
let pattern = /[^5-8]/g;

Try it yourself

Syntax

new RegExp("[^0-9]")

Or abbreviated as:

/[^0-9]/

Syntax with modifiers

new RegExp("[^0-9]", "g")

Or abbreviated as:

/[^0-9]/g

Browser support

/[^0-9]/ Is ECMAScript1 (ES1) feature.

All browsers fully support ES1 (JavaScript 1997):

Chrome IE Edge Firefox Safari Opera
Supports Supports Supports Supports Supports Supports

Regular expression search methods

In JavaScript, regular expression text search can be completed using different methods.

UsagePattern (pattern)As regular expressions, these are the most commonly used methods:

Example Description
text.match(pattern) string method match()
text.search(pattern) string method search()
pattern.exec(text) RexExp method exec()
pattern.test(text) RexExp method test()