logos icon indicating copy to clipboard operation
logos copied to clipboard

Regex not returning $1

Open rdearman opened this issue 3 years ago • 2 comments

I'm expecting the regular expression string to return the values inside the parentheses () similar to perl 's $1 so for a string of: my_label: I expect

    #[regex("([[:word:]]+):",lcaseit,  ignore(ascii_case) )]
    LABEL(String),

to return my_label without the : at the end. But it returns the entire string.

rdearman avatar Mar 20 '21 13:03 rdearman

It seems it does not have capturing groups for now: https://github.com/maciejhirsz/logos/issues/214#issuecomment-875521408 , nor lookahead, lookbehind, nor their negative counterparts.

castarco avatar Jul 16 '22 08:07 castarco

I would like to add a +1 to the request for supporting capture groups. It would be much more ergonomic (and probably faster) to return a capture directly from the regex than to pass the entire slice to a callback function and parse it all over again just to extract the relevant data.

InfiniteDissent avatar Nov 18 '22 12:11 InfiniteDissent