I have a text in which I would like to calculate occurences of the phrase "lorem ipsum dolor".
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Ipsum lorem dolor Curabitur ac risus nunc. Dolor ipsum lorem.
The algorithm should be counting occurrences even if the searching phrase is written in different order. I've highlighted expected results. Is there any better way to achieve that than using regular expression with every possible combination?
In this case the result should be equal to 3
- Lorem ipsum dolor
- Ipsum lorem dolor
- Dolor ipsum lorem
The phrase will have about 3-4 words and string will be a content of web page.