10.3.1 Matching

Probably one of the most common uses for regular expressions is checking whether a string matches the specific pattern. The match method of a regular expression object can be used to do that:

class Main {
  static function main() {
    var r = ~/world/;
    var str = "hello world";
    // true : 'world' was found in the string
    trace(r.match(str));
    trace(r.match("hello !")); // false
  }
}