I want to put a regex in a YAML config file (say: config/filename.yaml), eg.
-
section: Begining
regex: '/ ^ <[ a..b, A..B ]> /'
-
section: Next
regex: '/ ^ <[ c..z, C..Z ]> /'
When I read this into a hash (eg. using YAMLish), eg.,
use YAMLish;
my @h = load-yaml('config/filename.yaml'.IO.slurp);
naturally I have a string in @h[0]<regex>
So how do I recover a regex from a string for use in a match?
I want something like the following, but the following doesn't work:
say 'Its a beginning' if 'A beginning' ~~ @h[0]<regex>
It doesn't work as desired because @h[0]<regex> is a Str, so the smart match is testing a Str in @h[0]<regex> against a Str literal. So how to get the regex out of the Str?