I want to match the last character "c". What am I doing wrong? In the documentation it's clearly explained that $ matches the end of the line, i have used regex milions of time on unix shell ecc... and always worked as expected but in java no.
String string = "abc";
if(string.matches("c$")){//I know that .*c$ will work.
System.out.println("yes");//This is never printed
}
Where is the error? I know that .*c$ will work, but by reading the javadoc I can't find this information. Can some one tell me how do I interpret what is the meaning of this java official tutorial? https://docs.oracle.com/javase/tutorial/essential/regex/bounds.html
or this?
https://docs.oracle.com/javase/8/docs/api/java/util/regex/Pattern.html#sum
Am I not able to read? Because it seems pretty obvious, but I really can't find the solution, I fell really retarded in this moment!
Under java.lang.String there is a method who clearly say the following: matches(String regex) Tells whether or not this string matches the given regular expression.