Help language development. Donate to The Perl Foundation

ECMA262Regex zef:jnthn last updated on 2023-01-06


ECMA262Regex Build Status

This module allows you parsing ECMA262 regex notation and use it in Perl 6.


use v6;
use ECMA262Regex;

say ECMA262Regex.validate('\e'); # False;
say ECMA262Regex.validate('^fo+\n'); # True

# Translate regex into Perl 6 one (string form)
say'^fo+\n'); # '^fo+\n'
say''); # '<-[ab..d]>'

# Compile textual ECMA262 regex into Perl 6 Regex object
my $regex = ECMA262Regex.compile('^fo+\n');

say "foo\n"  ~~ $regex; # Success
say " foo\n" ~~ $regex; # Failure