Board index » delphi » Remove '.' from a string

Remove '.' from a string


2004-02-28 09:22:03 PM
delphi240
Is there an easy way to remove the '.' from a string?
Example:
2.01 should become 201
12.1 should become 121 (...)
thx
 
 

Re:Remove '.' from a string

"qsd" <sqdsq>wrote
Quote
Is there an easy way to remove the '.' from a string?
Can there be more than one '.'? --JohnH
 

Re:Remove '.' from a string

I hope that this is what you are looking for.
function DeleteSign(sSign : string; sString : string) : string;
var index : integer;
begin
index := pos(sSign, sString);
while (index <>0) do
begin
delete(sString, index, 1);
index := pos(sSign, sString);
end;
DeleteSign := sString;
end;
Call:
Edit1.Text := DeleteSign('.', Edit1.Text);
2.01 -->201
Am 28.02.2004 14:22 schrieb qsd:
Quote
Is there an easy way to remove the '.' from a string?
Example:
2.01 should become 201
12.1 should become 121 (...)

thx


 

Re:Remove '.' from a string

On Sat, 28 Feb 2004 14:22:03 +0100, qsd writes:
Quote
Is there an easy way to remove the '.' from a string?
Check AnsiReplaceText() with a null string for the AToText string
--
Good luck,
liz
 

Re:Remove '.' from a string

Thanks alot guys, you've been a great help!!
 

Re:Remove '.' from a string

There is a bug when sSign is longer than 1 char.
delete(sString, index, length(sSign));
[]s
Arthur
"Volker Jobst" <XXXX@XXXXX.COM>writes
Quote
I hope that this is what you are looking for.

function DeleteSign(sSign : string; sString : string) : string;
var index : integer;
begin
index := pos(sSign, sString);

while (index <>0) do
begin
delete(sString, index, 1);
index := pos(sSign, sString);
end;

DeleteSign := sString;
end;

Call:
Edit1.Text := DeleteSign('.', Edit1.Text);

2.01 -->201

Am 28.02.2004 14:22 schrieb qsd:
>Is there an easy way to remove the '.' from a string?
>Example:
>2.01 should become 201
>12.1 should become 121 (...)
>
>thx
>
>
 

Re:Remove '.' from a string

If you want something simple have a look at the StringReplace function in
SysUtils:
function DeleteSign(sSign : string; sString : string) : string;
begin
Result := StringReplace( sString, sSign, '', [rfReplaceAll] );
end;
regards
DM
"Arthur E.F.Heinrich" <XXXX@XXXXX.COM>writes
Quote
There is a bug when sSign is longer than 1 char.

delete(sString, index, length(sSign));

[]s
Arthur


"Volker Jobst" <XXXX@XXXXX.COM>writes
news:c1q6os$c2$01$XXXX@XXXXX.COM...
>I hope that this is what you are looking for.
>
>function DeleteSign(sSign : string; sString : string) : string;
>var index : integer;
>begin
>index := pos(sSign, sString);
>
>while (index <>0) do
>begin
>delete(sString, index, 1);
>index := pos(sSign, sString);
>end;
>
>DeleteSign := sString;
>end;
>
>Call:
>Edit1.Text := DeleteSign('.', Edit1.Text);
>
>2.01 -->201
>
>Am 28.02.2004 14:22 schrieb qsd:
>>Is there an easy way to remove the '.' from a string?
>>Example:
>>2.01 should become 201
>>12.1 should become 121 (...)
>>
>>thx
>>
>>


 

Re:Remove '.' from a string

Yeah, you are right, you have to replace
delete(sString, index, 1);
through
delete(sString, index, Length(sSing));
Thank you
Am 03.03.2004 01:39 schrieb Arthur E.F.Heinrich:
Quote
There is a bug when sSign is longer than 1 char.

delete(sString, index, length(sSign));

[]s
Arthur


"Volker Jobst" <XXXX@XXXXX.COM>writes
news:c1q6os$c2$01$XXXX@XXXXX.COM...

>I hope that this is what you are looking for.
>
>function DeleteSign(sSign : string; sString : string) : string;
>var index : integer;
>begin
>index := pos(sSign, sString);
>
>while (index <>0) do
>begin
>delete(sString, index, 1);
>index := pos(sSign, sString);
>end;
>
>DeleteSign := sString;
>end;
>
>Call:
>Edit1.Text := DeleteSign('.', Edit1.Text);
>
>2.01 -->201
>
>Am 28.02.2004 14:22 schrieb qsd:
>
>>Is there an easy way to remove the '.' from a string?
>>Example:
>>2.01 should become 201
>>12.1 should become 121 (...)
>>
>>thx
>>
>>