删除所有新行并使用 n 个字符制作单行
Remove all new lines and make single line with n character
正在生成 CSV。
我正在尝试创建一个包含多个下一行的描述字符串。
我试过了:
description = a.replaceAll("\n","\\n");
但是我得到了 \n 并且它没有出现在一行中
当前输出
IS0001;10381;Active Directory groups EU AD;SW;Internal applications;E\CIERORAD;CRP\E616053;16053;616053;radva.cierny@evry.com;E\XXJANDAM;CRP\E21494;7481;21494;ext.milsv.janda@evry.com;This tool allows users to view and manage delivery lists and groups in Active Directory. Everyone in EVRY will have access via https://int.eto.com
\n
\nAll users can view the distribution lists and security groups they are members of, with the exception of dynamic distribution lists. Dynamic distribution lists are based on Wo/ERP data, and they are usually for organizational units and some roles, e.g. line managers.
\n
\nGroup owners can view and manage their groups, including renewing and deleting groups, and adding and removing members of these groups.
\n
\nNew groups are created by requesting a group from My Support, there is no self-service for that.
期待:
IS0001;10381;Active Directory groups EU AD;SW;Internal applications;E\CIERORAD;CRP\E616053;16053;616053;radva.cierny@evry.com;E\XXJANDAM;CRP\E21494;7481;21494;ext.milsv.janda@evry.com;This tool allows users to view and manage delivery lists and groups in Active Directory. Everyone in EVRY will have access via https://int.eto.com \n\n All users can view the distribution lists and security groups they are members of, with the exception of dynamic distribution lists. Dynamic distribution lists are based on Wo/ERP data, and they are usually for organizational units and some roles, e.g. line managers. \n\nGroup owners can view and manage their groups, including renewing and deleting groups, and adding and removing members of these groups. \n\nNew groups are created by requesting a group from My Support, there is no self-service for that.
知道如何在一行中完成吗?
使用
实现
description = a.replace("\n", "\\n").replace("\r", "");
要用一个换行符替换多个 newlines/carriage-return 个字符(任意顺序),我会使用:
replaceAll("[\n\r]+", "\n")
真正总共创建一行(并且 \
+n
代替换行符):
replaceAll("\r?\n|\r", "\\n")
正在生成 CSV。 我正在尝试创建一个包含多个下一行的描述字符串。
我试过了:
description = a.replaceAll("\n","\\n");
但是我得到了 \n 并且它没有出现在一行中
当前输出
IS0001;10381;Active Directory groups EU AD;SW;Internal applications;E\CIERORAD;CRP\E616053;16053;616053;radva.cierny@evry.com;E\XXJANDAM;CRP\E21494;7481;21494;ext.milsv.janda@evry.com;This tool allows users to view and manage delivery lists and groups in Active Directory. Everyone in EVRY will have access via https://int.eto.com
\n
\nAll users can view the distribution lists and security groups they are members of, with the exception of dynamic distribution lists. Dynamic distribution lists are based on Wo/ERP data, and they are usually for organizational units and some roles, e.g. line managers.
\n
\nGroup owners can view and manage their groups, including renewing and deleting groups, and adding and removing members of these groups.
\n
\nNew groups are created by requesting a group from My Support, there is no self-service for that.
期待:
IS0001;10381;Active Directory groups EU AD;SW;Internal applications;E\CIERORAD;CRP\E616053;16053;616053;radva.cierny@evry.com;E\XXJANDAM;CRP\E21494;7481;21494;ext.milsv.janda@evry.com;This tool allows users to view and manage delivery lists and groups in Active Directory. Everyone in EVRY will have access via https://int.eto.com \n\n All users can view the distribution lists and security groups they are members of, with the exception of dynamic distribution lists. Dynamic distribution lists are based on Wo/ERP data, and they are usually for organizational units and some roles, e.g. line managers. \n\nGroup owners can view and manage their groups, including renewing and deleting groups, and adding and removing members of these groups. \n\nNew groups are created by requesting a group from My Support, there is no self-service for that.
知道如何在一行中完成吗?
使用
实现description = a.replace("\n", "\\n").replace("\r", "");
要用一个换行符替换多个 newlines/carriage-return 个字符(任意顺序),我会使用:
replaceAll("[\n\r]+", "\n")
真正总共创建一行(并且 \
+n
代替换行符):
replaceAll("\r?\n|\r", "\\n")