Subject | Re: Stripping non numerics from a string column |
---|---|
Author | jrodenhi |
Post date | 2007-07-20T19:27Z |
Rich,
I know this violates your basic premise that you don't want to have to
write your own function, but I would say that this is a problem that
begs for a udf solution. One of Firebird's major selling points is
the way that it allows you to extend it's functions with Delphi. I
wrote a function that I think does exactly what you need in Delphi. I
use it to strip the hyphens out of social security numbers. Here is
the function:
function StripChar(const sTarget: string; const sStripChar: string):
string;
var i: Integer;
s: String;
begin
s := sTarget;
for i := 1 to Length(sStripChar) do begin
While Pos(sStripChar[i], s) > 0 do
Delete(s, Pos(sStripChar[i], s), 1);
end;
Result := s;
end;
This gets included in my customized version of the tbudf dll. If that
would fix the problem for you, I would be glad to send the dll and its
source.
-Jack
I know this violates your basic premise that you don't want to have to
write your own function, but I would say that this is a problem that
begs for a udf solution. One of Firebird's major selling points is
the way that it allows you to extend it's functions with Delphi. I
wrote a function that I think does exactly what you need in Delphi. I
use it to strip the hyphens out of social security numbers. Here is
the function:
function StripChar(const sTarget: string; const sStripChar: string):
string;
var i: Integer;
s: String;
begin
s := sTarget;
for i := 1 to Length(sStripChar) do begin
While Pos(sStripChar[i], s) > 0 do
Delete(s, Pos(sStripChar[i], s), 1);
end;
Result := s;
end;
This gets included in my customized version of the tbudf dll. If that
would fix the problem for you, I would be glad to send the dll and its
source.
-Jack