Re: Parse a string into a regex?

2017-05-12 Thread Lloyd Fournier
eas > > On 11.05.17 10:32, Sean McAfee wrote: > > I've been searching for how to parse a string into a regex, like qr/$str/ > > does in Perl 5, but so far without success. > > > > At first I assumed, by analogy with .Str, .List, etc, that I could call > >

Re: Parse a string into a regex?

2017-05-12 Thread Andreas Mueller
IMHO it is a security and speed issu I switched it of with a pragma like this: use MONKEY-SEE-NO-EVAL; my $match = EVAL "/$m/"; if $test_string ~~ $match { say 'yea' } Andreas On 11.05.17 10:32, Sean McAfee wrote: > I've been searching for

Re: Parse a string into a regex?

2017-05-11 Thread Sean McAfee
On Thu, May 11, 2017 at 4:01 PM, Timo Paulssen wrote: > The only way that comes to mind is to use EVAL, but that's not > golf-friendly at all. > > Perhaps you can find something sufficiently short based on .contains, > .index, .starts-with, .ends-with, and friedns? > I'm open to suggestions. A

Re: Parse a string into a regex?

2017-05-11 Thread Patrick R. Michaud
Since we went to a lot of trouble to get lexical and closures to work correctly in Perl 6, it seems fair to use it here: $ cat rxstr sub rxstr($s) { rx/<$s>/ } my $str = 'foo'; my $foorx = rxstr($str); # create /foo/ regex say 'foo' ~~ $foorx; # matches $

Re: Parse a string into a regex?

2017-05-11 Thread Timo Paulssen
The only way that comes to mind is to use EVAL, but that's not golf-friendly at all. Perhaps you can find something sufficiently short based on .contains, .index, .starts-with, .ends-with, and friedns?

Parse a string into a regex?

2017-05-11 Thread Sean McAfee
I've been searching for how to parse a string into a regex, like qr/$str/ does in Perl 5, but so far without success. At first I assumed, by analogy with .Str, .List, etc, that I could call .Regex on a string, but this is not the case. On IRC's #perl6 I learned about the <$str>