Fandom

Delphi Programming

Parse

2,918pages on
this wiki
Add New Page
Talk0 Share

Ad blocker interference detected!


Wikia is a free-to-use site that makes money from advertising. We have a modified experience for viewers using ad blockers

Wikia is not accessible if you’ve made further modifications. Remove the custom ad blocker rule(s) and the page will load as expected.

Parsing Middle from a StringEdit

Uses:

  • StrUtils


Function:

function ParseMiddle(Buffer, Start, Finish: String): String;
var 
  PosStart, PosFinish, Num: Integer;
begin
  PosStart := Pos(Start, Buffer) + Length(Start);
  PosFinish := Posex(Finish, Buffer, PosStart);
  Result := Copy(Buffer, PosStart, PosFinish - PosStart);
end;


Usage:

  ParseMiddle('0123456789','3','8'); //= (4567)

Extract Number from a StringEdit

Function:


function ExtractNumberInString(AContainsNumber: String): String;
var
  CharIndex: Integer;
begin
  Result := '';
  for CharIndex := 1 to length(AContainsNumber) do
    if AContainsNumber[CharIndex] in ['0'..'9'] then
      Result := Result + AContainsNumber[CharIndex];
end;

Usage:

  ShowMessage(ExtractNumberInString('abcd1234defg')); //will show '1234

Also on Fandom

Random Wiki