private function validate($regex): void {
    if(@preg_match($regex, '') === false) {
      throw new InvalidArgumentException('Expected regex, but got [' . var_export($regex, true) . '] instead');
    }
  }