I have a text file that contains some strings separated by ",". Strings are in the form of: "x:somestring:any string". I'm interested in extracting "somestring" value only. I could extract "somestring:any string" by replacing the "x:" with "" using:
Pattern p= Pattern.compile("x:", Pattern.CASE_INSENSITIVE);
Matcher m = p.matcher("");
But as I said before, I'm interested only in "somestring". Is it possible to add a second pattern in order to replace ":any string" with "". I thought of repeating the same process again, but I wanted to ask about a better way. Is there any way to improve my regular expression? Please note that "somestring" and "any string" are not fixed values.