I have a String as in the example below
String a = "Meu pai é um Grande "baio" de fada";
I want to make it turn a String like this
String a = "Meu pai é um Grande \"baio\" de fada";
How do I do this using replaceAll?
I have a String as in the example below
String a = "Meu pai é um Grande "baio" de fada";
I want to make it turn a String like this
String a = "Meu pai é um Grande \"baio\" de fada";
How do I do this using replaceAll?
It would be something like:
String a = "Meu pai é um Grande "baio" de fada";
a = a.replaceAll("\"", "\\"");
In this case you will change any quotation marks found, regardless of whether it is "test
or "test"
.
But your question seems to me that it is more with RegEx, the use I believe it to be this:
String a = "Meu pai é um Grande "baio" de fada";
a = a.replaceAll("\"([^\"]+)\"", "\"$1\"");
In this case, you will look for all those within the quotation marks, such as "?asd?asd/A/sd;;lasd"
In case it can be something with with texts:
String a = "Meu pai é um Grande "baio" de fada";
a = a.replaceAll("\"([a-zA-Z0-9\s]+)\"", "\"$1\"");
In this case, you will look for all those within the quotation marks, such as "a e 0 9"