思想:trim函数,正则表达式 repaceAll()
代码如下:
public String deleteSpace(String s){ s=s.trim(); s=s.replaceAll("\\s{2,}", " "); return s; }
Powered by: 博客园 Copyright © 2024 骄阳照林 Powered by .NET 9.0 on Kubernetes