JavaScript RegExp [^0-9] Groups (not for number)2 Mar 2025 | 5 min read 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]. SyntaxThe following syntax is used to regex groups for unavailable numbers. Or Description :
ExamplesThe 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. ![]() 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. ![]() 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. ![]() 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. ![]() 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. ![]() ConclusionThe regex for number groups is used to validate the numerical value using the bracket with number [0-9]. |
HTML or DOM events are widely used in JavaScript code. JavaScript code is executed with HTML/DOM events. So before learning JavaScript, let’s have some idea about events. Events Description onclick occurs when element is clicked. ondblclick occurs when element is double-clicked. onfocus occurs when an element gets focus such as button, input, textarea...
1 min read
JavaScript string includes() The JavaScript includes() method is used to check if a specified substring is present in a given string. It is a case-sensitive method. It returns the Boolean value, either true or false. It returns true if the string contains the specified substring and...
2 min read
The getAttribute() method is used to get the value of an attribute of the particular element. If the attribute exists, it returns the string representing the value of the corresponding attribute. If the corresponding attribute does not exist, it will return an empty string or...
2 min read
What is ? List comprehension is a programming method that we use to create a new list with the help of operation to each item in an existing iterable in JavaScript. List comprehension is present in several different languages that help the users to enable the generation...
3 min read
What is Null in JavaScript? In JavaScript, null is a value that represents the intentional absence of any object value. It is technically a primitive type, although in some cases, it behaves as an object. In other words, null indicates the delibrate absence of any object value. It's...
3 min read
An inline function with a name, also known as an anonymous function and assigned to a variable in JavaScript. JavaScript does not provide support for the traditional concept of inline functions as C or C++. Accordingly, there is no distinction between inline and anonymous functions. They are...
3 min read
Introduction Data structures and algorithms structure the foundation of software engineering and programming. They are fundamental apparatuses for taking care of complicated issues productively and are urgent in building vigorous and versatile applications. In this masterclass, we will dive into the universe of JavaScript algorithms and data...
19 min read
Colors are an integral part of the look and feel of the website. Whether it might be online or offline, colors make the websites look beautiful and appealing. In JavaScript and HTML elements, color is applied to the background, text, and other elements. Colors are most...
8 min read
What is Class in JavaScript? In JavaScript, classes is a templates that can be used to create objects which can help us to encapsulate data and code to work on it. It is an object-oriented programming concept that was introduced in the ECMAScript 2015 which is also...
7 min read
What is ? InnerHTML is a property in JavaScript that allows you to access or edit the HTML content of an element. Receiving the innerHTML of an element returns the HTML content of that element as a string. If we want to pass JavaScript to the inner text...
4 min read
We request you to subscribe our newsletter for upcoming updates.
We provides tutorials and interview questions of all technology like java tutorial, android, java frameworks
G-13, 2nd Floor, Sec-3, Noida, UP, 201301, India