I'm trying to implement a search function.
The user types a phrase and I want to match any word from the phrase and the phrase itself in an array of strings.
The problem is that the phrase is stored in a variable, so the Pattern.compile method won't interpret its special characters.
I'm using the following flags for the compile method:
Pattern.CASE_INSENSITIVE | Pattern.UNICODE_CASE | Pattern.LITERAL | Pattern.MULTILINE
How could I achieve the desired result?
Thanks in advance.
edit: For example, the phrase:
"Dog cats donuts"
would result in the pattern:
Dogs | cats | donuts | Dogs cats donuts