Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function StrPosExpression(ignore: Char; s, str: string; var position: Integer; var expression: string): Boolean;
- var
- t: TStringArray;
- h, i, l, p, f: Integer;
- d: string;
- begin
- expression := '';
- position := 0;
- Result := False;
- l := Length(s);
- if ((l > 0) and not (l > Length(str))) then
- begin
- d := StringOfChar(ignore, 1);
- t := Explode(d, s);
- h := High(t);
- f := Pos(t[0], str);
- l := (f + Length(t[0]));
- if ((h > 0) and (f > 0)) then
- begin
- for i := 1 to h do
- begin
- p := PosEx(t[i], str, l);
- if (p > 0) then
- l := (p + Length(t[i]))
- else
- Exit;
- end;
- position := f;
- expression := Copy(str, f, (l - f));
- Result := True;
- end;
- end;
- end;
- var
- p: Integer;
- str, exp: string;
- begin
- str := 'WHAAAAAAAT THE HECK IS THIS... This is just a damn test to prove the command works! OK?!';
- ClearDebug;
- if StrPosExpression('*', 'This * damn test * works!', str, p, exp) then
- WriteLn('"' + exp + '" @' + IntToStr(p));
- end.
- end;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement