ktranslate icon indicating copy to clipboard operation
ktranslate copied to clipboard

[Feature request] Allow negative matches for regex in match_attributes

Open maxlemieux opened this issue 10 months ago • 1 comments

This request is to provide an equivalent feature to work around the lack of negative lookahead patterns in Golang regex for match_attributes.

Example which doesn't work (container will crash):

match_attributes:
  "!if_interface_name": "^(?!foobarbaz\b)\\S+"

It would be great if there was an operator to negate the match.

Example of workaround for this issue in Golang regex: https://regex101.com/library/7lMqca?page=862

maxlemieux avatar Apr 24 '24 21:04 maxlemieux

Will this work for you @maxlemieux?

        match_attributes:
            if_interface_name: enp1s0
            DOES_NOT_MATCH: true

A long time ago, the DOES_NOT_MATCH special case was added. It will invert any matches for a match_attributes block where it is present.

i3149 avatar May 01 '24 05:05 i3149

This issue is stale because it has been open 30 days with no activity. Remove stale label or comment or this will be closed in 5 days.

github-actions[bot] avatar Jun 06 '24 01:06 github-actions[bot]

This issue was closed because it has been stalled for 5 days with no activity.

github-actions[bot] avatar Jun 11 '24 01:06 github-actions[bot]

Great! This should work nicely for the purpose.

maxlemieux avatar Jun 15 '24 02:06 maxlemieux