I have a string like this
String myString = "I love [stackoverflow]";
What I want to do is to replace the character "["
to <span style="color:red;">
and the character "]"
to </span>
to change the color of
the word stackoverflow
to red.
So the expected string result is "I love <span style="color:red;">stackoverflow</span>"
I am new in regex so I tried like this
String myString = "I love [Stackoverflow]";
myString.replaceAll("[",<span style="color:red;">).replaceAll("]","</span>");
but seems not the correct way because the android studio says
unclosed character class
What is the correct regex of that single character?