How can I interpolate a variable into a Perl 6 regex?

后端 未结 1 426
庸人自扰
庸人自扰 2020-12-06 12:36

Synopsis 05 mentions that Perl 6 doesn\'t interpolate variables into a regex, but you can associate an external variable with a pattern. The docs don\'t mention this feature

相关标签:
1条回答
  • 2020-12-06 13:09

    As an alternative to using a closure, you can of course build the regex via EVAL.

    Besides these two arguably subpar solutions, I'm drawing a blank as well. Note that you can do more complex interpolations via the <{...}> syntax, eg

    / <{ BEGIN compute-string-once-at-compile-time }> /
    

    but I don't see how that can be used to solve the problem...

    0 讨论(0)
提交回复
热议问题