I want to find position in(
position within string, but I can not explicitly write:
int index = valueOf("in(");
because I get error of non closed group ( java.util.regex.PatternSyntaxException Unclosed group).
If I escape parenthesis it will not find index of in(
, but in\(
int index = value.indexOf("in\\(");
How can I achieve that?
EDIT: I indeed made an mistake in forming the question. In my code i use indexOf but the real problem was an String.split. But when I got PatternSyntaxException I somehow went to line where indexOf was, thus I started to fixing the issue in wrong place. When I escaped ( then indexOf did not find the "\(".
What I got confused and felt like loosing ground was what the eclipse did, then I post stackoverflow, what I do:
String value = "in(test";
String[] arr = value.split("in\\(");
so I have arr = {"","test"} as below:
but why? why I see value:
Why in array elements string value is shown as original string? Is it bug or feature?