Thank you William, that boolean condition check option looks like it is in the direction of the answer I sought.

FYI, the reason I spelled out the character class explicitly rather than using "<alpha>" was because I wanted it strictly applied to ASCII chars and not everything Unicode considers a char, and this seemed the best way to be sure.

-- Darren Duncan

On 2023-07-30 9:30 p.m., William Michels via perl6-users wrote:
Hi Darren (and Marcel),

Two different approaches:
https://docs.raku.org/language/regexes#Conjunction:_&&; <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 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>*

Reply via email to