Java去除字符串中的空格,回车,换行符,制表符

xiaoxiao2024-04-18  32

public class StringUtil{public static void replaceBlank(){ Pattern p = Pattern.compile(“\\s*|\t|\r|\n”); String str="I am a, I am Hello ok, \n new line ffdsa!"; System.out.println("before:"+str); Matcher m = p.matcher(str); String after = m.replaceAll(""); System.out.println("after:"+after);}public static void main(String[] args) { replaceBlank();}} 相关资源:敏捷开发V1.0.pptx
转载请注明原文地址: https://www.6miu.com/read-5015066.html

最新回复(0)