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?

[perl #131279] Can't index result of adverbial `[..]`

2017-05-11 Thread Zoffix Znet via RT
On Tue, 09 May 2017 10:41:57 -0700, c...@zoffix.com wrote: > When looking up something with `[...]` postcircumfix, you can add more > postcircumfixes to index the result: > > $ perl6 -e 'dd [*][1]' > "b" > > But this silently gives wrong results if adverbs are present as well: > > $ perl6 -e 'dd

[perl #131279] Can't index result of adverbial `[..]`

2017-05-11 Thread Zoffix Znet via RT
On Tue, 09 May 2017 10:41:57 -0700, c...@zoffix.com wrote: > When looking up something with `[...]` postcircumfix, you can add more > postcircumfixes to index the result: > > $ perl6 -e 'dd [*][1]' > "b" > > But this silently gives wrong results if adverbs are present as well: > > $ perl6 -e 'dd

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> construct, which d