Remove all combination of set at the end of string REGEX

I want to write a REGEX that removes all combination of a group of characters from the end of strings. For instance removes "k", "t", "a", "u" and all of their combinations from the end of the string:

Input:

["Rajakatu","Lapinlahdenktau","Nurmenkaut","Linnakoskenkuat"]

Output:

["Raja","Lapinlahden","Nurmen","Linnakosken"]

>Solution :

How about something like this [ktau]{4}\b?
https://regex101.com/r/BVwTcs/1

This will match at the end of a word for those character combinations.
For example, k, followed by u, followed by a, followed by t.

This can also match aaaa so take that into account.
It will match any 4 combinations of the characters at the end of the word.

Leave a Reply