Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is it possible to do boolean assertions with raku regex?

Tags:

regex

raku

rakudo

In the apocalypses, there are some words about boolean assertions:

<( code )>            # call code as boolean assertion

However, I cannot make it work.

say "9471" ~~ m:g/ (\d) <($0 > 5)> /

I expect to only match numbers greater than 5, but I get a compile error.

Which is the correct syntax (if exists), or any alternative to do some boolean assertion?

like image 456
Julio Avatar asked Nov 19 '20 09:11

Julio


Video Answer


1 Answers

See Boolean condition check

$ raku -e 'say "9471" ~~ m:g/ (\d) <?{ $0 > 5 }> /'
(「9」
 0 => 「9」 「7」
 0 => 「7」)
like image 118
Elizabeth Mattijsen Avatar answered Oct 26 '22 20:10

Elizabeth Mattijsen