From: "Volker W. Walter" Subject: Re: Remove comma(s) from String Date: 23 Apr 1999 00:00:00 GMT Message-ID: <37201A79.AB233C37@metrohm.ch> Content-Transfer-Encoding: 7bit References: <7fkdd2$4dm3@forums.borland.com> X-Accept-Language: en Content-Type: text/plain; charset=us-ascii Organization: Another Netscape Collabra Server User Mime-Version: 1.0 Newsgroups: borland.public.delphi.objectpascal Martin Kelly wrote: > > Is there a more efficient way of removing the comma characters from a > string? > > function RemoveCommas(aStr: String): String; > begin > // Remove Comma(s) from String > // e.g. 1,000,000.00 will now read 1000000.00 > while Pos(',', aStr) > 0 do > Delete(aStr, Pos(',', AStr), 1); > Result := aStr; > end; > > I could only come up with the above. > > Just curious. > > Martin Kelly I dont like to call Pos() twice per loop: perhaps someone likes this function RemoveCommas(aStr: String): String; VAR p:integer; BEGIN p:=Pos(',',aStr); WHILE (0