Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8624277
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T07:29:06+00:00 2026-06-12T07:29:06+00:00

I have to substitute a range of accented characters in a string with the

  • 0

I have to substitute a range of accented characters in a string with the respective non accented letters.
I was thinking of using re.sub but I have no clue of how to substitute more items (each one with a different item) at the same time.
So to be clearer:

import re
re.sub(r'è|ù|ò|à','e,u,o,a',string). 

First of all is this allowed in Python so to avoid to make a separate line for each letter?
Thanks!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-12T07:29:07+00:00Added an answer on June 12, 2026 at 7:29 am

    re.sub() can accept a function as the replacement, so you can do something like the following:

    reps = dict(zip('èùòà', 'euoa'))
    re.sub(r'è|ù|ò|à', lambda m: reps[m.group(0)], some_string)
    

    Example:

    >>> re.sub(r'è|ù|ò|à', lambda m: reps[m.group(0)], 'à ò ù è')
    'a o u e'
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

If I have the following code: var value : String = StringUtil.substitute(The value {0}
We have been getting a range on infuriating error dialogs using Visual Studio 2008
how to call a function from the substitute string in vim? When i have:
I have an SQL template where I need to substitute random UUIDs. from string
I have substitute my memcache with Redis. I use the phpredis client and the
I have assembly with my framework and assembly with tests. But I need to
nowadays I have this piece of code: #import C:\Users\Public\SoundLog\DLLs\ForPython\SoundLogDLL.tlb named_guids but I want to
This has been driving me absolutely nuts. I have a substitute function like this:
I would like to query using hibernate given a particulay query string I did
I'd like to have a substitute or print style command with a regex working

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.