Troubles with special characters in Perl

Posted on 2000-03-22
Last Modified: 2010-03-05
I´m from Mexico, i want to manipulate strings in Perl which had character "´", for example, i want manipulate word México and convert to Mexico ¿ how can i do that ?
Question by:grivera032200
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2

Author Comment

ID: 2645897
Adjusted points from 50 to 100
LVL 84

Expert Comment

ID: 2646053
($string = "México") =~ tr/é/e/;

Accepted Solution

sniperrus earned 100 total points
ID: 2770883
Tr/// is really your best shot, just compile a list of characters to be replaced and the list or replacement characters and execute something like :

$string =~ tr/[é¿]/[e ]/ig;

The elements of the left list are replaced with the corresponding elemnts in the right list. The i and g switches tell the command to make the substitutions on a case insensitive basis (although you are better off providing alternatives in respective cases for this) and to make substitutions globally, i.e. not to stop with only one substitution.

Author Comment

ID: 2771350
Thanks for comments,
LVL 84

Expert Comment

ID: 2771364
/ig is invalid syntax for tr
Also, translating [ to [, and ] to ] is not very useful.

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In the distant past (last year) I hacked together a little toy that would allow a couple of Manager types to query, preview, and extract data from a number of MongoDB instances, to their tool of choice: Excel (…
Checking the Alert Log in AWS RDS Oracle can be a pain through their user interface.  I made a script to download the Alert Log, look for errors, and email me the trace files.  In this article I'll describe what I did and share my script.
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…

726 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question