请问怎么去掉字符中间的空格??

JerryOne 2004-03-24 08:35:33
如:ABC abc 如何变成 ABCabc
...全文
47 10 打赏 收藏 转发到动态 举报
写回复
用AI写文章
10 条回复
切换为时间正序
请发表友善的回复…
发表回复
JerryOne 2004-03-26
  • 打赏
  • 举报
回复
感谢大家,结贴!
yzwpf 2004-03-25
  • 打赏
  • 举报
回复
AnsiReplaceStr():case-sensitive
AnsiReplaceText():case-insensitive
也可以。
AnsiReplaceStr(const AnsiString AText, const AnsiString AFromText, const AnsiString AToText);

Call AnsiReplaceStr to scan the string specified by AText and replace all occurrences of the string specified by AFromText with the string specified by AToText. Occurrences of AFromText are identify by a case-sensitive comparison. The identification of substrings is not recursive: if the substitution of AToText results in a new match for AFromText, that match is not replaced.
gxd791127 2004-03-24
  • 打赏
  • 举报
回复
同意楼上
fjye 2004-03-24
  • 打赏
  • 举报
回复
老妖果然强啊,真方便。
ccrun.com 2004-03-24
  • 打赏
  • 举报
回复
为何不试试这个?

String strTemp = "ww xw wx xwwxxxw wxxww";
strTemp = StringReplace(strTemp, " ", "", TReplaceFlags() << rfReplaceAll);
serafini 2004-03-24
  • 打赏
  • 举报
回复
找到字串中的空格删除即可!
WbtServer 2004-03-24
  • 打赏
  • 举报
回复
没有找到好的方法。
gfh_79_0 2004-03-24
  • 打赏
  • 举报
回复
AnsiString Str,temp;
temp="";
Str=Edit1->Text;
for(int i=1;i<Str.Length()+1;i++){
if(Str.SubString(i,1)==" "){
}
else {
temp=temp+Str.SubString(i,1);
}
}
ShowMessage(temp);
szcyx 2004-03-24
  • 打赏
  • 举报
回复
void AllTrim(char *str)
{
char temp[80];
int i, j;
strcpy(temp,str);
i = j = 0;
while(temp[i] != 0)
{
if(temp[i] != ' ' && temp[i] != '\t')
{
str[j++] = temp[i];
}
i++;
}
str[j] = 0;
}
fjye 2004-03-24
  • 打赏
  • 举报
回复
AnsiString a="ABC abc";,b;
b = a.SubString(1,a.Pos(" ")-1);
a = a.SubString(a.Pos(" "),a.Length());
b += Trim(a);

如果有多个空格,用个循环,以此类推

13,825

社区成员

发帖
与我相关
我的任务
社区描述
C++ Builder相关内容讨论区
社区管理员
  • 基础类社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

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