Ho una corda e quando cerco di eseguire il metodo replaceAll
, sto ottenendo questo strano errore:Java String ReplaceAll metodo che genera un errore di ripetizione illegale?
String str = "something { } , op";
str = str.replaceAll("o", "\n"); // it works fine
str = str.replaceAll("{", "\n"); // does not work
e ottengo uno strano errore:
Exception in thread "main" java.util.regex.PatternSyntaxException:
Illegal repetition {
Come posso sostituire le occorrenze di "{"
?
Forse cambia anche il commento :) –
@KublaiKhan: :) – codaddict
@codaddict, grazie – Johnydep