"
([\\\\/])(?=\\1)" is a Java
String literal. Each backslashrequires another to escape it, so the resulting String object has this content: "
([\\/])(?=\1)"
The Java class
Pattern also requires a backslash to escape another one, so the pattern for matching is "
([\/])(?=\1)"
Of this,
[\/] is a character class that matches a single occurrence of
\ or
/. It is enclosed in parentheses
([\/]) to create capturing group / back reference #1.
(?= introduces a non capturing positive lookahead and
\1 matches the content of the back reference #1.
So effectively, this matches either of
\ or
/ where the next character is also the same.
References: java.util.regex.Pattern javadoc and
http://www.regular-expressions.info/tutorial.html
http://www.regular-expressions.info/brackets.html
Hm, now that I think about it the regex can be shortened to
([\/])\1 or as a Java String literal "
([\\\\/])\\1" -- a lookahead isn't really needed.