JavaScript RegExp [^abc] Expression
The RegExp [^abc] Expression in JavaScript is used to search for any character which is not between the brackets. The character inside the brackets can be a single character or a span of characters.
- [A-Z]: It is used to match any character from uppercase A to uppercase Z.
- [a-z]: It is used to match any character from lowercase a to lowercase z.
- [A-z]: It is used to match any character from uppercase A to lowercase z.
- [abc…]: It is used to match any character between the brackets.
Syntax:
/[^abc]/
or
new RegExp("[^abc]")Syntax with modifiers:
/\[^abc]/g
or
new RegExp("[^abc]", "g")Example 1: This example searches the characters which are not present between [A-G] i.e uppercase A to uppercase G in the whole string.
html
<!DOCTYPE html><html lang="en"><head> <title> JavaScript RegExp [^abc] Expression </title></head><body> <h1 style="color:green"> GeeksforGeeks </h1> <h2>RegExp [^abc] Expression</h2> <p> GEEKSFORGEEKS is the computer science portal for geeks. </p> <button onclick="geek()"> Click it! </button> <p id="app"></p> <script> function geek() { let str1 = "GEEKSFORGEEKS is the computer " + "science portal for geeks."; let regex4 = /[^A-Z]/g; let match4 = str1.match(regex4); document.getElementById("app").innerHTML = "Found " + match4.length + " matches: " + match4; } </script></body></html> |
Output:
![RegExp [^abc] Expression](https://web.archive.org/web/20230528170508im_/https://media.geeksforgeeks.org/wp-content/uploads/20230105171917/animation-of-reg.gif)
RegExp [^abc] Expression
Example 2: This example searches the characters which are not present between [a-g] i.e lowercase a to lowercase g in the whole string.
html
<!DOCTYPE html><html lang="en"><head> <title> JavaScript RegExp [^abc] Expression </title></head><body> <h1 style="color:green"> GeeksforGeeks </h1> <h2>RegExp [^abc] Expression</h2> <p> GEEKSFORGEEKS is the computer science portal for geeks. </p> <button onclick="geek()"> Click it! </button> <p id="app"></p> <script> function geek() { let str1 = "GEEKSFORGEEKS is the computer " + "science portal for geeks."; let regex4 = /[^a-p]/g; let match4 = str1.match(regex4); document.getElementById("app").innerHTML = "Found " + match4.length + " matches: " + match4; } </script></body></html> |
Output:
![RegExp [^abc] Expression](https://web.archive.org/web/20230528170508im_/https://media.geeksforgeeks.org/wp-content/uploads/20230105172124/animation-of-reg2.gif)
RegExp [^abc] Expression
Supported Browsers: The browsers supported by RegExp [^abc] Expression are listed below:
- Google Chrome
- Apple Safari
- Mozilla Firefox
- Opera
- Internet Explorer
We have a complete list of Javascript RegExp expressions, to check those please go through this JavaScript RegExp Complete Reference article.
We have a Cheat Sheet on Javascript where we covered all the important topics of Javascript to check those please go through Javascript Cheat Sheet-A Basic guide to JavaScript.



Please Login to comment...