In HACKERRANK this line of code occurs very frequently. I think this is to skip whitespaces but what does that "\r\u2028\u2029\u0085"
thing mean
scanner.skip("(\r\n|[\n\r\u2028\u2029\u0085])?");
Scanner.skip skips a input which matches the pattern, here the pattern is :-
\n newline
\u2028 matches the character with index 2018 base 16(8232 base 10 or 20050 base 8) case sensitive
1st Alternative \r\n
2nd Alternative [\n\r\u2028\u2029\u0085]
Skip \r\n
is for Windows.
The rest is standard \r=CR
, \n=LF
(see \r\n , \r , \n what is the difference between them?)
Then some Unicode special characters:
u2028 = LINE SEPARATOR
(https://www.fileformat.info/info/unicode/char/2028/index.htm)
u2029 = PARAGRAPH SEPARATOR
(http://www.fileformat.info/info/unicode/char/2029/index.htm)
u0085 = NEXT LINE
(https://www.fileformat.info/info/unicode/char/0085/index.htm)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With