Fix issue where having conflicting pattern items in the search query
could lead to erroneous results. For example, if the search query was
`test\c\C\c`, one would expect for the case sensitivity option to be
disabled, seeing as `\c` is the last pattern item. However, since the
code was simply iterating over `PATTERN_ITEMS`, it did not take into
consideration that:
1. The same pattern item could appear more than once in the query 2. The
order of the pattern item in the query should take precedence over the
order of the pattern item in `PATTERN_ITEMS`
As such, this commit fixes that so that the implementation actually
iterates over the pattern items capture in the query, ensuring that, if
`\c\C\c` is found, the last pattern item is the one that will be
applied.