把不是空格的字符串进行替换
2009-12-11 05:05
260 查看
代码
1 unit Unit1;
2
3 interface
4
5 uses
6 Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
7 StdCtrls;
8
9 type
10 TForm1 = class(TForm)
11 Button1: TButton;
12 procedure Button1Click(Sender: TObject);
13 private
14 { Private declarations }
15 public
16 { Public declarations }
17 end;
18
19 var
20 Form1: TForm1;
21
22 implementation
23
24 {$R *.DFM}
25
26 procedure TForm1.Button1Click(Sender: TObject);
27 var
28 s:string;
29 i:integer;
30 begin
31 i:=1;
32 s:='123abc';
33 while(i<=length(s))and(s[i]<>'')do
34 begin
35 s[i]:='f';
36 inc(i);
37 showmessage(inttostr(i));
38 showmessage(s);
39 end;
40 end;
41 end.
1 unit Unit1;
2
3 interface
4
5 uses
6 Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
7 StdCtrls;
8
9 type
10 TForm1 = class(TForm)
11 Button1: TButton;
12 procedure Button1Click(Sender: TObject);
13 private
14 { Private declarations }
15 public
16 { Public declarations }
17 end;
18
19 var
20 Form1: TForm1;
21
22 implementation
23
24 {$R *.DFM}
25
26 procedure TForm1.Button1Click(Sender: TObject);
27 var
28 s:string;
29 i:integer;
30 begin
31 i:=1;
32 s:='123abc';
33 while(i<=length(s))and(s[i]<>'')do
34 begin
35 s[i]:='f';
36 inc(i);
37 showmessage(inttostr(i));
38 showmessage(s);
39 end;
40 end;
41 end.
相关文章推荐
- 剑指offer系列之二:字符串空格替换
- 算法-字符串替换空格
- 字符串替换空格
- 替换字符串中的空格
- 字符串空格替换练习题
- JS使用replace()方法和正则表达式进行字符串的搜索与替换实例
- java 将字符串中多个空格替换成一个空格
- oracle中如何对字符串进行去除空格的方法
- 替换字符串中的空格4
- 字符串空格替换
- 程序员面试金典第一章:数组与字符串(4) 空格替换
- 【剑指offer】请实现一个函数,将一个字符串中的空格替换成“%20”。例如,当字符串为We Are Happy.则经过替换之后的字符串为We%20Are%20Happy。
- 替换空格-请实现一个函数,将一个字符串中的空格替换成“%20”。例如,当字符串为We Are Happy.则经过替换之后的字符串为We%20Are%20Happy。
- 截取实际长度字符串,并用空格替换
- 字符串中替换空格
- 把字符串中的空格替换为"%20"
- 把字符串中的每个空格替换程“%20”,例如输入“I love my hometown”,输出为”I%20love%20my%20hometown”
- 把字符串中的每个空格替换程“%20”,例如输入“I love my hometown”,输出为”I%20love%20my%20hometown”
- 替换字符串中的空格
- javascript将字符串中的多个空格替换为一个空格的正则实例