Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

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:

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

["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.

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading