Tc(match) for regex matching without replacing

Currently regex matching can be achieved like this:

tc(reg, <text>, "[\s\S]*(<pattern>)[\s\S]*", "$1")

I propose

tc(match, <text>, <pattern>, <optional group index>)
2 Likes

This can be done but i am not sure how is this any different, i mean you can already do:

$if(tc(reg, <text>, "[\s\S]*(<pattern>)[\s\S]*", "$1"), "do something")$

Am i missing something?

Yeah you can already achieve matching via matching the entire string and replacing it with the content of a group, but this would be simpler to use. Dunno if there’s a big need for this, regex is already an advanced feature so maybe people that know regex don’t need a simpler way to match?

Most languages have a way to use regex to replace, test and get the match/matches. In Kustom we have a way to replace and test, but matching requires what is effectively a workaround. It’s not like this is a bug, it’s just something to consider. Figured I’d throw it onto the forum when I was explaining to someone how to extract information from some part of a string and it occured to me tc(match) would be easier to explain.

Ok, its trivial to add so it doesn’t need to be a big use case your arguments are enough :slight_smile:

1 Like