Hi to all coders out there. Let me do this straight.
I want to replace all character in a string inside a opening and closing brackets.
what I have in my code.
string value= str.replaceAll("\\[.*\\]", "strToReplace");
It's working , but the problem is it also delete the brackets.
ex:
I want to say [Hello].
the result:
I want to say .
How can I achieve that? Anyone? Thanks in Advance. It will be a really big help in me.
String s = str.replaceAll("\[.*\]", "strToReplace")
to
String s = str.replaceAll("\[.*?\\]", "["+"strToReplace"+"]")
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With