DELAPARRA
Index
Color
NL
Category: Regex flags

/L (Locale-dependent)

Explained by Updated

What is /L (Locale-dependent)?

/L (Locale-dependent): Makes \w, \b, \s (and case conversion) depend on the current C locale rather than a fixed Unicode/ASCII table. The L flag, found in Python for byte patterns, makes classes such as \w and case-insensitive matching follow the current system locale. A server set to a Turkish or French locale can then treat letters differently from one set to English.

Definition source Coders Lingo, CC BY 4.0

Frequently asked questions about /L (Locale-dependent)

How is /L (Locale-dependent) used in practice?

That is exactly why it is rarely a good idea. The same code can behave differently on your laptop, the CI server and production, depending on environment settings nobody remembers to check. Bugs like that are slow to find.

What should you keep in mind with /L (Locale-dependent)?

Python 3 discourages the flag for text and only allows it for bytes. Use Unicode-aware matching, which is the default for str patterns, or the ASCII flag when you need strict rules. Both give the same result on every machine. If you inherit code with re.LOCALE, treat it as a small risk to clean up rather than a feature to keep.

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.