删除所有新行,并制作一条包含n个字符的单行



生成CSV。我正在尝试创建一个描述字符串,它有多个下一行。

我试过了:

description = a.replaceAll("n","\\n");

但我得到了,它不是一行

电流输出

IS0001;10381;Active Directory groups EU AD;SW;Internal applications;ECIERORAD;CRPE616053;16053;616053;radva.cierny@evry.com;EXXJANDAM;CRPE21494;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;ECIERORAD;CRPE616053;16053;616053;radva.cierny@evry.com;EXXJANDAM;CRPE21494;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 nn 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. nnGroup owners can view and manage their groups, including renewing and deleting groups, and adding and removing members of these groups. nnNew groups are created by requesting a group from My Support, there is no self-service for that.

知道如何在一行中制作吗?

使用实现

description = a.replace("n", "\\n").replace("r", "");

要用一个换行符替换多个换行符/回车符(任何顺序(,我会使用:

replaceAll("[nr]+", "n")

要真正总共创建一行(用+n代替换行(:

replaceAll("\r?\n|\r", "\\n")

最新更新