I wonder if there is any groovy -way to check if a substring of strings matches patterns.
For example, I have a list of strings (or an array):
def Errors = ['File xyz cannot be created: No space left on device', 'File kjh has errors: some_error']
Then I have a list of strings, for example def Patterns = ['Tests failed', 'No space left on device', 'Something goes wrong', ...some strings... ]
I would like to check if some List Patterns elements are substrings of Errors elements.
In this example, it should return true because Patterns has No space left on device and Errors has 'File xyz cannot be created: No space left on device' .
I know how to write this very unevenly and inefficiently using two loops and the contains method, but I know that Groovy has much more powerful built-in methods. I tried with findAll() but it didn't work at all.
Do you have any ideas? Is there a way to make it smarter?
source share