Rand Stats

Polyglot::Regexen

zef:guifa

Polyglot::Regexen

A module to enable use of non-Raku flavors of regex directly in Raku code.

Why?

Because copy and paste. Also, there are lots of little gotchas when going between different flavors. What counts for \s, \d, ., or even $ can vary substantially or in quite subtle ways. If you have a battle-tested regex, don't worry about rewriting it. Just use it as is!

The goal of this module is to provide a variety of ways for you to use your favor flavors in Raku scripts — even in grammars!
When using regexen from this module, you can be assured that capture ordering is preserved, the meaning of whitespace won't get changed, etc.

Support

The support for different flavors is shown below in a table, followed by a discussion on any (hopefully temporary) deviations from the standard. The meaning of the columns is the following:

FlavorIn grammarsBare quoted (substitution)Lexical scopedadverb
ECMA-262 (Javascript)✓ (𐄂)ecma
Python𐄂𐄂 (𐄂)𐄂py
Ruby𐄂𐄂 (𐄂)𐄂ruby
PHP𐄂𐄂 (𐄂)𐄂php

(At the moment, only Javascript is supported. The others are aspirational.)

Support Caveats

Version History