split兼容\r\n 和\n
时间: 2023-08-15 10:07:22 浏览: 138
根据引用\[1\]中的代码和引用\[2\]中的运行结果,可以得出split函数在处理字符串时是兼容"\r\n"和"\n"的。当字符串中包含"\r\n"或"\n"时,split函数会将其作为分隔符进行分割。例如,当字符串为"a\r\nb"时,split函数会将其分割为\["a", "b"\]。同样地,当字符串为"a\nb"时,split函数也会将其分割为\["a", "b"\]。因此,split函数是兼容"\r\n"和"\n"的。
#### 引用[.reference_title]
- *1* *3* [golang中strings.split的使用,分割](https://blog.csdn.net/ens160/article/details/119950837)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v91^insertT0,239^v3^insert_chatgpt"}} ] [.reference_item]
- *2* [Java String.split()函数的用法和正则表达式](https://blog.csdn.net/wangchaox123/article/details/90670233)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v91^insertT0,239^v3^insert_chatgpt"}} ] [.reference_item]
[ .reference_list ]
阅读全文