Hello,
I have a question regarding regular expressions and the Pattern.matches function. Right now I'm experimenting around a bit and found a strange behaviour I can't explain. Maybe some of you can.
Let's say we have:
Why do all three matches yield true?String s= "abc\nabc"; System.out.println(Pattern.matches("abc\nabc", s)); System.out.println(Pattern.matches("abc\\nabc", s)); System.out.println(Pattern.matches("abc\\\nabc", s));
For the second one it's clear, since \n is a regex-expression and the first backslash quotes it. But the rest is not so clear, especially the third one. Can someone explain it to me?