program regexp;

{$APPTYPE CONSOLE}

uses
  System.Text.RegularExpressions;

var
  RegexObj: Regex;
  s: System.String;
  list: array of System.String;
  func, test: System.String;
  mymatch: Match;  
begin
//sub(column(1), column(2))
  try
    // first way
  
    RegexObj := Regex.Create('sub\(column\([0-9]+\), column\([0-9]+\)\)');
    Console.WriteLine(RegexObj.IsMatch('sub(column(1), column(19))').ToString());
    list := Regex.Split('sub(column(1), column(19))', '(sub\(column\(|\), column\(|\)\))');
    for s in list do
    begin
      Console.WriteLine(s);
    end;

    // second way
    func := 'sub(column(Number), column(Number))';
    test := 'sub(column(1), column(19))';
    RegexObj := Regex.Create(Regex.escape(func).Replace('Number', '[0-9]+'));
    Console.WriteLine(RegexObj.ToString());

    mymatch := RegexObj.Match(test);
    if (mymatch.Success and (mymatch.Length = test.Length)) then
    begin
    	Console.WriteLine(test + ' and ' + func + ' do match!');
    end;
    // the following matches even 123test456 with test:    
    Console.WriteLine(RegexObj.IsMatch(test).ToString());
    list := Regex.Split(test, Regex.escape(func).Replace('Number', '|'));
    for s in list do
    begin
      Console.WriteLine('>' + s);
    end;
    
    list := Regex.Split('abcdefghijklmnopqrstuvwxyz', '(a|e|i|o|u)');
    for s in list do
    begin
      Console.WriteLine(s);
    end;

  except on e: Exception do
    begin
      Console.WriteLine(e.ToString());
    end;
  end;
  Console.ReadLine();

  { TODO -oUser -cConsole Main : Insert code here }
end.