I have to split a String if it has this format below
String test="City: East Khasi Hills";
and some times i may get String test="City:";
I want to match the pattern if there is any words after ":",
I am using
String city=test.matches(":(.*)")?test.split(":")[1].trim():"";
But my regex is returning false. tired of debugging by the way i am using regex online tool to test my string.
I am getting a match in the tool. but java is returning me false.
Stringin the first place, and why?