ExpandCollapseNext Index

+ 0.1 tre-1.01-0.flx

  open Tre;
  open C_hack;
  open Carray;
  
  print$ "Using tre " tre_version; endl;
  
  var r = tre_regcomp("(a|b)*abb");
  print "Done tre compile"; endl;
  
  print
    match r with
    | Some _ => "Compiled"
    | #None => "failed"
    endmatch
  ;
  endl;
  
  
  var re : tre_regex_t =
    match r with
    | Some re => re
    | #None => re // HACK!
    endmatch
  ;
  
  var s = "aabbabababb";
  res,n,a := tre_regexec re s;
  print "Result = "; print res; endl;
  print "nmatches = "; print n; endl;
  
  var i : int;
  for_each { i=0; } { i<n } { ++i; }
    {
      if int(a.i.rm_so) == -1 do
        print i; print " -> nomatch\n";
      else
        print i; print "-> match '";
        start := int(a.i.rm_so);
        finish := int(a.i.rm_eo);
        print s.[start to finish];
        print "'"; endl;
      done;
    }
  ;
  
  print "Finished"; endl;
  

Using tre TRE 0.8.0 (BSD)
Done tre compile
Compiled
Result = 0
nmatches = 2
0-> match 'aabbabababb'
1-> match 'b'
Finished