• 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
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

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
 
All of the world's problems can be solved in a garden - Geoff Lawton. Tiny ad:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic