

Task

   match a string against a regular expression
   substitute part of a string using a regular expression


 
use RegEx;
 
bundle Default {
  class RegExTest {
    function : Main(args : String[]) ~ Nil {
      string := "I am a string";
      # exact match
      regex := RegEx->New(".*string");
      if(regex->MatchExact(".*string")) {
        "ends with 'string'"->PrintLine();
      };
      # replace all
      regex := RegEx->New(" a ");
      regex->ReplaceAll(string, " another ")->PrintLine();
    }
  }
}
 