I need to create regex using java to capture substrings that satisfies following conditions:
- Either starts with "34" or "37"
- are 15 digits long (ex. "379081815400122")
My code is:
import java.util.Date;
import java.util.regex.Pattern;
public class HelloWorld {
public static void main(String[] args) {
String text = "\\\"370000000000000\\\"";
String pattern = "3[47][0-9]{13}";
boolean matches = Pattern.matches(pattern, text);
System.out.println("matches = " + matches);
}
}
https://onecompiler.com/java/3xjcp4ycr
but it not working and prints false instead of true. I don't understand what modification it requires to print true as my text contain "370000000000000" which is 15 digit and starts with 37.