关于Java代码中的问题,尤其是在跳过函数中的部分。

huangapple go评论89阅读模式
英文:

A problem about the code in java especially in skip function

问题

scanner.skip("(\r\n|[\n\r\u2028\u2029\u0085])?");

can anyone please explain this code...
i'm still confusing about this code and how this code works while compiling

英文:
scanner.skip("(\r\n|[\n\r\u2028\u2029\u0085])?");

can anyone please explain this code...
i'm still confusing about this code and how this code works while compiling

答案1

得分: 1

scanner.skip("(\r\n|[\n\r\u2028\u2029\u0085])?");

你可以阅读预定义字符类的所有详细信息:

https://docs.oracle.com/javase/10/docs/api/java/util/regex/Pattern.html

查找水平空白和换行匹配器。
英文:
  scanner.skip("(\r\n|[\n\r\u2028\u2029\u0085])?");

You can read all the details of predefined character classes:

https://docs.oracle.com/javase/10/docs/api/java/util/regex/Pattern.html

Look for horizontal white space and linebreak matcher.

答案2

得分: 0

这段代码告诉扫描器在输入中跳过不需要的字符,忽略分隔符。

在这种情况下,一组与换行处理相关的字符会被跳过:

英文:

This code tells scanner to skip unwanted characters in the input ignoring delimiters.

In this case, a set of characters related to new-line handling are skipped:

答案3

得分: 0

Explanation for the string:

\r\n - 一对CRLF,类似于Windows中的换行符,

\r - CR(回车)MacOS换行符,

\n - LF(换行)Unix换行符,

\u2028 - Unicode换行符,

\u2029 - Unicode段落分隔符,

\u0085 - Unicode下一行。

英文:

Explanation for the string:

\r\n - a pair of CRLFs like in Windows, or any of the following single characters:

\r - CR (carriage return) MacOS line separator,

\n - LF (line feed) Unix line separator,

\u2028 - Unicode line separator,

\u2029 - Unicode paragraph separator,

\u0085 - Unicode next line.

huangapple
  • 本文由 发表于 2020年8月25日 13:36:26
  • 转载请务必保留本文链接:https://go.coder-hub.com/63572626.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定