Regexp Match Multiple Words in Any Order Aug 23rd 2021 Words: 73

In a given text paragraph:

1
2
3
4
basket 1: cherry peach banana apple lemon litchi
basket 2: cherry apple banana lemon litchi
basket 3: apple banana litchi lemon cherry peach
basket 4: apple litchi lemon

In order to find the line that contains a given combination of keyword (order-insensitive), use the following pattern:

1
(?=.*lemon)(?=.*peach)

It matched basket 1 and 3 in the above example

Reference: