Regex to Match Non-ASCII Characters
Copy the pattern, paste your text, and watch every character outside the ASCII range light up. Below: how to strip them safely.
Regex pattern
/[^\x00-\x7F]/g
This matches any character outside the 7-bit ASCII range (code points above 0x7F), such as emoji or accented letters. Replace the matches with '' to strip a string down to plain ASCII.
What this pattern matches
[^\x00-\x7F] matches any character whose code point is outside the 7-bit ASCII range (0–127). That includes accented letters, smart quotes, em dashes and emoji.
Strip them out
Replace every match with an empty string: text.replace(/[^\x00-\x7F]/g, ''). To replace with a placeholder instead, put it in the replacement.
Careful with emoji
Emoji and other astral characters are made of surrogate pairs; this pattern removes each half, which is fine for stripping but not for counting. Use the u flag and \p{ASCII} in modern engines for code-point-aware handling.
Use it in your code
import re
text = "Caf\u00e9 na\u00efve r\u00e9sum\u00e9 \u2014 emoji \ud83d\ude00 and smart quotes \u201cok\u201d. Plain ASCII stays."
pattern = r'''[^\x00-\x7F]'''
for m in re.finditer(pattern, text):
print(m.group())
const text = "Caf\u00e9 na\u00efve r\u00e9sum\u00e9 \u2014 emoji \ud83d\ude00 and smart quotes \u201cok\u201d. Plain ASCII stays.";
const re = new RegExp(String.raw`[^\x00-\x7F]`, "g");
console.log(text.match(re));
FAQ
How do I delete all non-ASCII characters?
Replace /[^\x00-\x7F]/g with an empty string.
Does it catch smart quotes and em dashes?
Yes. Those are non-ASCII punctuation, so they are matched and can be normalised to plain ' and -.
Is it emoji-safe?
For stripping, yes. For counting or slicing, use the u flag so surrogate pairs are treated as one character.