Home > Mobile >  groovy List comparisons
groovy List comparisons

Time:10-13

I have a list with 4 directories example:

[dir1,dir2/dir3,dir4,dir7]

Then I have a second list: These are full full filenames with paths

[dir1/file1.txt,dir8/file2.ext,dir4/dir5/dir6/file4.ext, dir2/dir3/file4.ext]

I want to find the intersection and in this case return:

[dir1,dir4,dir2/dir3]

CodePudding user response:

Assuming these are lists of strings.

And assuming you just want to know if the 4 directories prefix the second list entries.

And assuming you don't have some requirement to use a regex

  • Related