regexhelper
Test a pattern. Copy a ready-made one. No signup.

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.

/ /

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.

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.