• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • Devaka Cooray
  • Ron McLeod
  • Jeanne Boyarsky
Sheriffs:
  • Liutauras Vilda
  • paul wheaton
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Piet Souris
  • Carey Brown
  • Tim Holloway
Bartenders:
  • Martijn Verburg
  • Frits Walraven
  • Himai Minh

Handling Diacriticals in JAVa

 
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I need help with removing diacriticals in a string in Java.

In javascript u can use the unescape('%F8') to unescape the character and then do a replace by to replace it with some other character..
for ex:
text = replace(text,unescape('%C0'),'A');

how to implement this in Java??
I looked and did not find any already existing method or java class to do unescape.....someone please help
 
Ranch Hand
Posts: 133
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
String has a replaceall method, you can pass a regexp to replace uncommon chars.
 
ragini venkataraman
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
thanks but i am not able to understand how to write a regex for a diacritical....
say i have something like this(`a a grave and c circonflex) in a string then how to construct a regex to remove it?? can annyone give me an example to understand this....


thanks,
ragini
 
Jaime M. Tovar
Ranch Hand
Posts: 133
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
public class Untitled1 {
public static void main(String [] args) {
System.out.println("aAzZ09��d-_�".replaceAll("[^\u0061-\u007A\u0020-\u003F]",""));
}
}

Hope it helps
 
What kind of corn soldier are you? And don't say "kernel" - that's only for this tiny ad:
the value of filler advertising in 2021
https://coderanch.com/t/730886/filler-advertising
reply
    Bookmark Topic Watch Topic
  • New Topic