2015-08-28 24 views
1

我想为所有'/'字符添加尾随和前导空格,但只有当这些位置中没有空格时才会添加尾随和前导空格,做一个.Replace("/","/")如果不存在,将尾随和前导空格添加到字符串中的字符

所以串
This/is fine/these should be replaced hi/there/nice/to/meet/you
应该成为
This/is fine/these should be replaced hi/there/nice/to/meet/you

回答

1

你可能分裂,然后修剪后的结果归队。假设你不关心可能丢失的空白,如果有多于一个的话。

Dim parts = Text.Split("/"c).Select(Function(t) t.Trim) 
Dim result = String.Join("/", parts) 
相关问题