Solved

How do I strip string for specific characters

Posted on 2011-02-15
5
374 Views
Last Modified: 2012-05-11
I have a string entered dynamically, that I want to strip for any characters, that is not english. Example: Jürgen should be Jrgen.
How would I do that.
0
Comment
Question by:petersego
  • 3
  • 2
5 Comments
 
LVL 75

Expert Comment

by:Michel Plungjan
ID: 34904385
Why not Jurgen or Juergen
0
 
LVL 75

Expert Comment

by:Michel Plungjan
ID: 34904480
Anyway
str = str.replace(/[^a-zA-Z]/g,"")
0
 

Author Comment

by:petersego
ID: 34904491
Because I dont know what special characters might be used. There might be dozens of unknown characters like ê, ë, õ, æ and I cant make rules for everyone.
But if its possible I would love it.
0
 
LVL 75

Accepted Solution

by:
Michel Plungjan earned 500 total points
ID: 34904530
I would find a page with some standard replacement rules.
Off the top of my head:

ö,ø => oe
ä,æ => ae
å => aa
ü => ue
èéë => e

then there are some language specific ones, like ÿ in Dutch can be ij
http://en.wikipedia.org/wiki/Diacritic

But perhaps more important WHY do you want to replace? If everything is in UTF8, then no need to
0
 

Author Closing Comment

by:petersego
ID: 34904551
Yes, you are right about the replacement rules - too. Thanks a lot.
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

I have been doing hardcore actionscripting for some time; and needless to say I have faced a lot of problems in just understanding others' code rather than understanding what the code executes. A programmer's life can become hell when there are a lo…
The last time I worked with Flash and Socket connections was in AS1. A recent project required flash connecting to a Socket, and sending receiving information - we figured it would be easy enough - we all know about the socket policy documents and c…
The goal of the tutorial is to teach the user how to select which audio input to use. Once you have an audio input plugged into the laptop or computer, you will go into the audio input settings and choose which audio input you want to use.
The goal of the tutorial is to teach the user what frame rate is, how to control it and what effect it has on the video.

867 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

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now