字符串中连续多空格如何一次性都换成单个空格
如s=" a b c f"
如何变成s=" a b c f"
------解决方案--------------------------------------------------------
clear
s=" a b c f"
?s
?MyStrtran(s)
Function MyStrtran
Lparameters tcStr
For lnI=100 To 2 Step -1 && 100 表示最大支持长度是100的空格,可根据需求更改此值
tcStr=Strtran(tcStr,Space(lnI),Space(1))
EndFor
Return tcStr
Endfunc
------解决方案--------------------------------------------------------
2个空格换成一个空格,换到没2个空格为止。
Do While [ ]$s
s=strtran(s,[ ],[ ])
enddo