I have two questions.
1:
String = xx yy **
I want to remove “xx ” so String becomes = “yy *” (xx/yy is fixed and * can be anything)
I tried something like this but it does not work:
string.replaceall("^(xx )$", "");
Isn’t this supposed to replace the first occurence of “xx ” with “” ?
SOLVED(by Lucas)
2:
String = xx yy **
I want to remove ” yy **” so that String becomes = “xx”
I thought something like this, but since the first doesnt work i suspoect this will not too.
string.replaceall("^( yy)*$", "");
UNSOLVED
I actually phrased this one insufficiently,
xx should be **
so xx is not fixed
** yy **
should become ** which is the first **
Try this for the question1:
for the second one:
EDIT:
if regex is not a must, we can use this for the second one:
EDIT2: If ‘\n’ will be included in the string, this works for the second one: