I am trying to find the string that starts and ends both with “1” and only has “0” in between(could have no zero). How to write regex to get the matched substring?
Why this code doesn’t work?
Pattern p = Pattern.compile("(10*1)");
Matcher m = p.matcher(binaryString);
while(m.find()){
System.out.println(m.group(1));
}
e.g. input: 1101, output: 101, 11