gpt4 book ai didi

Java Pattern.quote ("\\d c pb sddsf\n");为什么

转载 作者:行者123 更新时间:2023-11-30 09:23:17 25 4
gpt4 key购买 nike

为什么 \n 没有被打印出来?

System.out.println(Pattern.quote("\\d c pb sddsf \n"));

基本上所有的东西都打印出来\n。有什么线索吗?它应该“文字化”整个字符串,不是吗?

如其所说here :

Metacharacters or escape sequences in the input sequence will be given no special meaning.

最佳答案

\n 是一个有效的 java 转义字符,用反斜杠将其转义以将其视为普通字符。:

    System.out.println(Pattern.quote("\\d c pb sddsf \\n"));

关于Java Pattern.quote ("\\d c pb sddsf\n");为什么,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16151607/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com