我有以下数据的csv文件如何通过正则表达式删除java中的空行我尝试使用^,+$
但它无法正常工作
“Temp-A007”,“默认”,“导入”,“”,“”,“”
“”, “”, “”
答案 0 :(得分:1)
您可以通过RegEx来完成。只需使用input : "Temp-A007", "","Default","Importing","","",""
output : "Temp-A007", "Default","Importing",
<强>输出强>
public class Test {
public static void main(String args[]) {
String input = new String("\"Temp-A007\", \"\",\"Default\",\"Importing\",\"\",\"\",\"\" ");
String output = input.replaceAll("(\"\\s*\"\\s*,?)", "");
System.out.println("input : " + input);
System.out.println("output : " + output);
}
}
<强>代码强>
<basicHttpBinding>
<binding name="abc_Windows" maxReceivedMessageSize="2147483647" messageEncoding="Mtom" transferMode="Streamed">
<security mode="TransportCredentialOnly">
<transport clientCredentialType="Windows" proxyCredentialType="None" realm="" />
<message clientCredentialType="UserName" algorithmSuite="Default" />
</security>
</binding>
</basicHttpBinding>
答案 1 :(得分:0)
“空”行最多只包含逗号,引号和空格,不是吗?怎么样:
^[", ]*$