DELAPARRA
Index
Color
NL
Category: Regex flags

/a (ASCII-only)

Explained by Updated

What is /a (ASCII-only)?

/a (ASCII-only): Restricts \w, \b, \s, \d (and case-insensitive matching) to ASCII characters only, instead of full Unicode. The ASCII flag limits shorthand classes such as \w, \d, \s and \b to plain ASCII characters. In Python it is re.ASCII or (?a). Without it, Python 3 treats letters like é, ß and Chinese characters as word characters too.

Definition source Coders Lingo, CC BY 4.0

Frequently asked questions about /a (ASCII-only)

How is /a (ASCII-only) used in practice?

That difference matters when you validate input. A pattern like ^\w+$ for a username will accept José by default, and reject it with the ASCII flag. Neither is wrong, but you should choose on purpose.

What should you keep in mind with /a (ASCII-only)?

For identifiers that end up in URLs, file names or older systems, ASCII-only rules avoid surprises further down the line. For names, addresses and any text written by people, full Unicode is usually what you want. Whatever you pick, test with a few accented and non-Latin examples, not just the English words you used while writing the pattern.

At a glance

CategoryRegex flags
Explained by
Updated

More Regex flags terms

All terms starting with a number or symbol

Skills

Download all skills (zip)

Manuals

Related services

Need any help?

Stuck on one of these in your own project? Tell me what you are working on and I will tell you how I would approach it.