Home > database >  Regex for filtering names
Regex for filtering names

Time:11-12

I´m very new to regex world and would like to know how to filter a list of names

List<String> names = ['Workspace1', 'Workspace2', 'Workspace3@tmp', 'Workspace4', 'Workspace1@tmp']

I want to get only Workspace* which are not followed by @tmp

How can I do it with groovy script ?

Thanks for help

CodePudding user response:

You can get all entries which start Workspace and then not an @ with

List<String> filtered = names.grep(~/^Workspace[^@]/)
  • Related