Last Updated : 05 Aug, 2025
The RegExp \D Metacharacter in JavaScript is used to search non-digit characters i.e all the characters except digits. It is the same as [^0-9].
JavaScript
let str = "a1234g5g5";
let regex = /\D/g;
let match = str.match(regex);
console.log("Found " + match.length + " matches: " + match);
Found 3 matches: a,g,gSyntax:
/\D/
Example 1: Searches the non-digit characters in the whole string.
JavaScript
let str = "GeeksforGeeks@_123_$";
let regex = /\D/g;
let match = str.match(regex);
console.log("Found " + match.length + " matches: " + match);
Found 17 matches: G,e,e,k,s,f,o,r,G,e,e,k,s,@,_,_,$
Example 2: Searches the non digit characters in the string.
JavaScript
let str = "Geeky@128";
let regex = new RegExp("\\D", "g");
let match = str.match(regex);
console.log("Found " + match.length
+ " matches: " + match);
Found 6 matches: G,e,e,k,y,@Difference Between \d and \D
Character Type
\d Matches
\D Matches
Digits (0-9)
Yes
No
Digits (0-9)
No
Yes
Symbols (@, #, $, etc.)
No
Yes
Whitespace (spaces, tabs, newlines)
No
Yes
Recommended Links:RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4