0

I have to replace a string whit special character like this: XY_Universit�-WWWWW-ZZZZZ in another one like: XY_Universita-WWWWW-ZZZZZ.

I tryed solutions like stringToReplace.replaceAll(".*Universit.*", "Universita"); but it replace all the string with the word ''Universita" and it isn't what i want.

Thanks in advance

F

user2864740
  • 60,010
  • 15
  • 145
  • 220
Zany
  • 308
  • 1
  • 4
  • 18
  • 1
    `.*` *eagerly* matches. In any case I suspect the *real* question is really "How to map Unicode characters with accents to the English-letter equivalent?" eg. see http://stackoverflow.com/questions/18350798/removing-accents-from-string , http://stackoverflow.com/questions/3322152/is-there-a-way-to-get-rid-of-accents-and-convert-a-whole-string-to-regular-lette – user2864740 Oct 13 '14 at 08:38

1 Answers1

1
 public static void main(String[] args) throws IOException {
        String exp = "XY_Universit�-WWWWW-ZZZZZ";
        exp = exp.replaceAll("Universit[^a]", "Universita");
        System.out.println(exp);
    }

Output

XY_Universita-WWWWW-ZZZZZ
Ankur Singhal
  • 26,012
  • 16
  • 82
  • 116