空格可能是连续一片,或跳着出现
还有回车换行也要去掉
str1:=StringReplace(str1, #13, '',[rfReplaceAll, rfIgnoreCase]);
showmessage(str1);
str1:=StringReplace(str1, #10, '',[rfReplaceAll, rfIgnoreCase]);
showmessage(str1);
str1:=StringReplace(str1, ' ', '',[rfReplaceAll, rfIgnoreCase]);
showmessage(str1);
我这样写能去掉一部分,但去不掉所有的.
还有我想把str1[index]='';这样写怎么不行?另:字符串可能很长
还有回车换行也要去掉
str1:=StringReplace(str1, #13, '',[rfReplaceAll, rfIgnoreCase]);
showmessage(str1);
str1:=StringReplace(str1, #10, '',[rfReplaceAll, rfIgnoreCase]);
showmessage(str1);
str1:=StringReplace(str1, ' ', '',[rfReplaceAll, rfIgnoreCase]);
showmessage(str1);
我这样写能去掉一部分,但去不掉所有的.
还有我想把str1[index]='';这样写怎么不行?另:字符串可能很长
解决方案 »
- 简单的delphi exe的目录更改问题
- 现有EXE程序,调整为带界面的ocx控件形式?
- RichEdit的使用(关于定位)?
- 请教在SQL Server数据库里,如何实现把一个表的数据系数插入到另一个表中?
- 如何让程序在任务栏中显示出来!
- 关于oracle数据库的备份与恢复
- 问一个关于用ADO连接SQL SEVRE 2000的问题
- 各位老大 请问用delphi 开发 通过pda来访问的web应用 用什么技术?
- parodax 7 类型的数据库怎样连接到Table控件?
- 什么是“IDAPI”?为什么提示“Cannot load an IDAPI service library ”?
- 连接数据库,有谁遇到这么怪的问题?请高手帮忙。
- 简单的数字乘除运算,急用!
Delete(str1, Index, 1);
Insert('xx', str1, Index);—————————————————————————————————
宠辱不惊,看庭前花开花落,去留无意;毁誉由人,望天上云卷云舒,聚散任风。
—————————————————————————————————
str1: Widestring;
str2:string;
index:integer;
begin
str1:='aaaaaaaaaaaaaaaaaaaaaaaaaa';
str2:='bbbbbbbbbbbbbbbbbbbbbbbbbb';
index:=0;
str1[index]:='';
str2[index]:='';
//................................
[Error] java.pas(99): Incompatible types: 'WideChar' and 'String'
[Error] java.pas(100): Incompatible types: 'Char' and 'String'
var
str:String ;
beginstr:=' a b c f h j';
str:=trim(str);
showmessage(Str);
end;
结果: a b c f h j'
If the Flags parameter does not include rfReplaceAll, StringReplace only replaces the first occurrence of OldPattern in S. Otherwise, all instances of OldPattern are replaced by NewPattern.If the Flags parameter includes rfIgnoreCase, The comparison operation is case insensitive.只要你指定了rfreplaceall 就应该可以换掉所以的子串的!!
实在不行你设一个循环:先用 pos 定位看看有没有子串,然后再stringreplace.应该可以成功的!
后,后面那部分就包含很多空格了,可能有255字符长度的问题.str1[index]='';这样写怎么不行?提示[Error] java.pas(100): Incompatible types: 'Char' and 'String'.我记得可以的呀另:来的都有分(偶写了trim不行的,再说trim的没有)
myStr:=Trim(myStr);
myStr:=AnsiReplaceStr(myStr,' ','');
str1[index]='';这样写怎么不行?提示[Error] java.pas(100): Incompatible types: 'Char' and 'String'.
怎么没人回答?
Char 类型没有空值,如果想置空,一般用 #0。