Is anyone aware of any R package that supports complex boolean + wildcard text matching implemented in some web interfaces - i.e. using AND
OR
*
?
()
/{}
operators? For example a function that can handle queries in the following formats (all examples return TRUE):
s = "The quick brown fox jumps over the lazy dog"
boolean_match(s, "fox AND dog")
boolean_match(s, "fox OR bird")
boolean_match(s, "f?x")
boolean_match(s, "The quick * dog")
boolean_match(s, "lazy AND (fox OR bird)") # i.e. nested logic
boolean_match(s, "(pretty AND bird) OR (quick AND (fox OR squirrel))") # recursive
This question asks the same but has not received much interest. I'm aware of the stringi
package - e.g. stri_detect_regex(s, c("fox","dog"))
, potentially combined with all()
/any()
- but it seems unable to handle the nested logic. Attempting conversion of this sort of complex query structure to REGEX seems suicidal.
Any suggestions much appreciated.