I know that this kind of questions are proposed very often, but I can't figure out why this RegEx does not match. I want to check if there is a "M" at the beginning of the line, or not. Finaly, i want the path at the end of the line. This is why startsWith() doesn't fit my Needs.
line = "M 72208 70779 koj src\com\company\testproject\TestDomainf1.java";
if (line.matches("^(M?)(.*)$")) {}
I've also tried the other way out:
Pattern p = Pattern.compile("(M?)");
Matcher m = datePatt.matcher(line);
if (m.matches()) {
System.out.println("yay!");
}
if (line.matches("(M?)(.*)")) {}
Thanks
line.charAt(0)?)M?means "0 or 1Mcharacters", which will always be true.