I think I get confused about Java's regular expression backslash. Sometimes we need double backslash. However,sometimes we need just one. For example why \.
(what does this mean?) can not match a normal dot, it needs \\.
However, the \t
can match the tab. If someone put arbitrary number of backslash, how to interpret the meaning. For example if I write \\\\t
, what does it mean.
Asked
Active
Viewed 41 times
0
-
Also see [Reference - What does this regex mean?](http://stackoverflow.com/questions/22937618/reference-what-does-this-regex-mean) – Wiktor Stribiżew Aug 28 '15 at 21:51
-
In short, it's because the \ character is already predefined for Java Strings. Also see: http://www.vogella.com/tutorials/JavaRegularExpressions/article.html – ihgann Aug 28 '15 at 21:58
-
Backslash is a escape character in Java and Regular Expression. – Andie2302 Aug 28 '15 at 22:52
-
\\\\t gets to \\t and this matches a backslash followed by t – Andie2302 Aug 28 '15 at 22:56