Link to home
Start Free TrialLog in
Avatar of Paulstott
Paulstott

asked on

VB functions in delphi

Hi EE

I was wondering if there was a left, mid, right and split functions in delphi? Also I want to remove/replace any ' characters in a string is this possible?

Thanks in advance

Paul
Avatar of Lukasz Zielinski
Lukasz Zielinski
Flag of Poland image

You can use Copy() to get left, right and mid characters and StringReplace() to replace and Delete() to remove.

ziolko.
Avatar of Paulstott
Paulstott

ASKER

Hi Ziolko,

Thanks for your answer

Would you use the pos function with the copy()? Do you have any example of this?

With string replace I have tried:

StringReplace(aString, ' ' ', ' ', [rfReplaceAll, rfIgnoreCase]); and get an error message, how can I get rid of ' (apostrophe).

Is there a split function or a way to get round this?
ASKER CERTIFIED SOLUTION
Avatar of Lukasz Zielinski
Lukasz Zielinski
Flag of Poland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
probably need to double up the '

StringReplace(aString, ' '' ', ' ', [rfReplaceAll, rfIgnoreCase]);
Here is another split string function I have been using.
Passes back the first string up to the delimiter while also trimming the original string.

function SplitStr(Var AString : String; ADelim : String) : String;
var APos : Integer;
begin
  Result := '';
  APos := Pos(ADelim,AString);
  if APos > 0 then
  begin
    Result := Copy(AString,1,APos-1);
    AString := copy(Astring,APos+length(Adelim),MaxLongInt);
  end
  else
  begin
    Result := AString;
    AString := '';
  end;
end;
Thanks for your help