Re: Raku regex assert doesn't match
[email protected] (Marcel Timmerman)
| Newsgroups | perl.perl6.users |
|---|---|
| Message-ID | <[email protected]> |
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>)