DZone
Thanks for visiting DZone today,
Edit Profile
  • Manage Email Subscriptions
  • How to Post to DZone
  • Article Submission Guidelines
Sign Out View Profile
  • Post an Article
  • Manage My Drafts
Over 2 million developers have joined DZone.
Log In / Join
Refcards Trend Reports
Events Video Library
Refcards
Trend Reports

Events

View Events Video Library

Related

  • Building an Identity-Aware MCP Server in Python
  • Build Your First Knowledge Graph From Unstructured Documents Using Python
  • Containerizing and Testing a Python Backtesting System With Docker and GitHub Actions
  • Python in 2026: uv vs Poetry vs pip: The Definitive Comparison

Trending

  • Securing Loop Engineering: Six Trust Boundaries for Autonomous Agents
  • Structured Logging in Distributed Systems: What Most Teams Get Wrong and How to Fix It
  • Agentic AI in 2026: How Autonomous AI Agents Are Replacing Manual Dev Work
  • A Practical Pipeline for Identifying Sensitive Columns Before Test Data Masking
  1. DZone
  2. Coding
  3. Languages
  4. Handling Accented Characters With Python Regular Expressions

Handling Accented Characters With Python Regular Expressions

By 
Richard Barrett-small user avatar
Richard Barrett-small
·
Feb. 27, 06 · Code Snippet
Likes (0)
Comment
Save
Tweet
Share
7.6K Views

Join the DZone community and get the full member experience.

Join For Free
[A-z] just isn't good enough!


import re
string = 'riché'
print string
riché

richre = re.compile('([A-z]+)')
match = richre.match(string)
print match.groups()
('rich',)

richre = re.compile('(\w+)',re.LOCALE)
match = richre.match(string)
print match.groups()
('rich',)

richre = re.compile('([é\w]+)')
match = richre.match(string)
print match.groups()
('rich\xe9',)

richre = re.compile('([\xe9\w]+)')
match = richre.match(string)
print match.groups()
('rich\xe9',)

richre = re.compile('([\xe9-\xf8\w]+)')
match = richre.match(string)
print match.groups()
('rich\xe9',)

string = 'richéñ'
match = richre.match(string)
print match.groups()
('rich\xe9\xf1',)

richre = re.compile('([\u00E9-\u00F8\w]+)')
print match.groups()
('rich\xe9\xf1',)

matched = match.group(1)
print matched
richéñ


Python (language)

Opinions expressed by DZone contributors are their own.

Related

  • Building an Identity-Aware MCP Server in Python
  • Build Your First Knowledge Graph From Unstructured Documents Using Python
  • Containerizing and Testing a Python Backtesting System With Docker and GitHub Actions
  • Python in 2026: uv vs Poetry vs pip: The Definitive Comparison

Partner Resources

×

Comments

The likes didn't load as expected. Please refresh the page and try again.

  • RSS
  • X
  • Facebook

ABOUT US

  • About DZone
  • Support and feedback
  • Community research

ADVERTISE

  • Advertise with DZone

CONTRIBUTE ON DZONE

  • Article Submission Guidelines
  • Become a Contributor
  • Core Program
  • Visit the Writers' Zone

LEGAL

  • Terms of Service
  • Privacy Policy

CONTACT US

  • 3343 Perimeter Hill Drive
  • Suite 215
  • Nashville, TN 37211
  • [email protected]

Let's be friends:

  • RSS
  • X
  • Facebook