---
title: "去除全角、半角空格"
author: "wlhok"
date: "2007-11-06T17:43:52Z"
tags: []
slug: "untitled"
draft: false
lastmod: "2007-11-06T17:43:52Z"
id: 138588
url: "https://wlh.iteye.com/blog/138588"
---

java 代码

1. private static String deleteFullSpace(String testStr) {
2. // ^\[ \*| \*]\*"表示以全角空格或半角空格开始的所有集合
3. // \[ \*| \*]\*$"表示以全角空格或半角空格结尾的所有集合
4. String resultStr = testStr.replaceAll("^\[　\*| \*]\*", "").replaceAll(
5. "\[　\*| \*]\*$", "");
6. return resultStr;
7. }