• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 381
  • Last Modified:

How do I strip string for specific characters

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
petersego
Asked:
petersego
  • 3
  • 2
1 Solution
 
Michel PlungjanIT ExpertCommented:
Why not Jurgen or Juergen
0
 
Michel PlungjanIT ExpertCommented:
Anyway
str = str.replace(/[^a-zA-Z]/g,"")
0
 
petersegoAuthor Commented:
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
 
Michel PlungjanIT ExpertCommented:
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
 
petersegoAuthor Commented:
Yes, you are right about the replacement rules - too. Thanks a lot.
0

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

  • 3
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now