Hi Darren (and Marcel),

Two different approaches:
https://docs.raku.org/language/regexes#Conjunction:_&&;

>From the docs:
*"For example if you have a regex quoted that matches a quoted string, then
`/ <quoted> && <-[x]>* /` matches a quoted string that does not contain the
character `x`."*

Second approach :
https://stackoverflow.com/questions/64909029/is-it-possible-to-do-boolean-assertions-with-raku-regex
https://docs.raku.org/language/regexes#Regex_Boolean_condition_check

Testing "Regex Boolean condition check" with a one-liner:

~ % cat  cats_dogs_jays.txt
cat
dog
jay
null cat
false dog
true jay
~ % raku -ne 'put $/ if $_ ~~ m:g/ ( <wb> <alpha>+ <wb> ) <!{ $0 eq "null"
| "false" | "true" }> /;'  cats_dogs_jays.txt
cat
dog
jay
cat
dog
jay


HTH, Bill.



On Jul 30, 2023, at 08:59, Marcel Timmerman <mt1...@gmail.com> wrote:

On 30-07-2023 06:21, Darren Duncan wrote:

Hello, I have a Raku regex question.

See the following:

    token nonquoted_alphanumeric_text
    {
        <!before [null | false | true] <wb>>
        <[ A..Z _ a..z ]> <[ 0..9 A..Z _ a..z ]>*
    }

What I want is for "nonquoted_alphanumeric_text" to match any simple ASCII
bareword EXCEPT a few special cases indicated in the example.

I was hoping there might be some better way of specifying this than my
example.

Is there any more direct way in Raku to say, match this pattern initially,
but if the result equals these exceptional values then treat it as having
not matched.

I am looking for a fully declarative solution in the grammar itself, not
something involving post-processing.

Thank you.

-- Darren Duncan

You can try: <|wb><ALPHA><ALNUM>*



(From: https://docs.raku.org/language/regexes#Predefined_character_classes
<https://docs.raku.org/language/regexes#Regexes>
<https://docs.raku.org/language/regexes#Predefined_character_classes>)

Reply via email to