summaryrefslogtreecommitdiff
path: root/fpcsrc/tests/webtbs/tw14236.pp
blob: 70ecb9ff26192dbbecce589780921b50d5d75305 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43

program project1;
// Run the following to cause an access violation
//
// ./project1 'as.*0' 'ascii_lf1'
//

{$mode objfpc}{$H+}

uses
  regex,
  SysUtils;

var
  re : TRegexEngine;
  aErrorPos : integer;
  aErrorCode: TRegexError;
  MatchPos : integer;
  Offset : integer;
  s1,s2 : string;
begin
  s1:='as.*0';
  s2:='ascii_lf1';
  try
    WriteLn('Regex: Trim(s1) = >>'+Trim(s1)+'<<');
    WriteLn('Test: Trim(s2) = >>'+Trim(s2)+'<<');
    re := TRegexEngine.Create(Trim(s1));
    if re.Parse(aErrorPos,aErrorCode) then begin
      Offset := 1;
      if re.MatchString(s2,MatchPos,Offset) then begin
        WriteLn('Match');
      end else begin
        WriteLn('No Match');
      end;
    end else begin
      WriteLn('Parse Failed');
    end;
  except
    on E : Exception do begin
      WriteLn('Exception: '+E.Message);
    end;
  end;
end.