To give a full answer we need to know (a) in what attribute these codes are stored and (b) if the attribute is a of type String, List or Set.
So, I'll
assume the values are stored in a String-type attribute $MyString. As it is a String, we know there is only one value of $MyString per note. I'm testing in TB v5.12.2
Thus our agent's query is:
$MyString.contains("^K")This matches any note where $MyString starts with a K, i.e. it is not a case sensitive match. so, on the agent's Rename dialog, tick the "Case sensitive" tick box to make the match case sensitive. Now, it won't match an empty attribute, "kden", "kDEN", or "BTHL". But it would match "KDE" or "KDEEN". To deal with the latter we should be able to use:
$MyString.contains("^K([A-Z]{3})$")The parentheses () are to set a back-reference to part of the matched string so we can use it in the agent action:
$MyStringA = $1The $1 value is it the 3 letters after the K captured in the () in the agent query (
see more). I've used a new attribute $MyStringA so you can test the outcome without damaging the source data. Once happy, you can delete the $MyStringA attribute change the agent action to:
$MyString = $1Here's a screengrab of my test: