有沒有方法把一個字串里的所有空格都去掉﹐包括字串前后和中間的都去掉

lionkings 2002-07-06 10:00:04
有沒有方法把一個字串里的所有空格都去掉﹐包括字串前后和中間的都去掉
...全文
31 6 打赏 收藏 转发到动态 举报
写回复
用AI写文章
6 条回复
切换为时间正序
请发表友善的回复…
发表回复
banalman 2002-07-06
  • 打赏
  • 举报
回复
同意 killerdanny(danny)
yang1105 2002-07-06
  • 打赏
  • 举报
回复
先用trim,再循环判断。
killerdanny 2002-07-06
  • 打赏
  • 举报
回复
global type f_replace from function_object
end type

forward prototypes
global function string f_replace (string orstr, string substr, string repstr)
end prototypes

global function string f_replace (string orstr, string substr, string repstr);int pp,ll;
string szTmp
///////////////
szTmp = orstr;
pp = Pos(lower(szTmp),lower(substr));
do while pp >0
szTmp=Replace(szTmp,pp,len(substr),repstr);
pp += len(repstr);
if szTmp="" then return '';
pp = Pos(lower(szTmp),lower(substr),pp);
loop
//orstr = sztmp;
return szTmp;
end function

//此函数从指定的字串中用自己字串替代要被替代的字串。
hycao 2002-07-06
  • 打赏
  • 举报
回复
这个方法可以一试:
String ls_string1, ls_string2, ls_temp
Integer i
ls_string1 = " AB CD "
For i = 1 To Len(ls_string1)
ls_temp = Mid(ls_string1, i, 1)
If ls_temp <> " " Then
ls_string2 += ls_temp
End If
Next
bys_home 2002-07-06
  • 打赏
  • 举报
回复
能行
你自己做一个嵌套函数
jianghuxing 2002-07-06
  • 打赏
  • 举报
回复
去掉前面,后面的可以用 trim 如果都要去掉就要用循环,逐个判断 了

1,076

社区成员

发帖
与我相关
我的任务
社区描述
PowerBuilder 相关问题讨论
社区管理员
  • 基础类社区
  • WorldMobile
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧