stuck with a regex issue

How do I have to modify the regex below to have all true except the last one (taxi)? Can't figure out what's wrong. Many thanks.

library(stringr)
txt <- c("New York", "Hello New York, how are you", "New Yorker coffe", "New Yorker taxi")
str_detect(txt, regex("New York[a-z]*?\\b(?!taxi)"))
#> [1] TRUE TRUE TRUE TRUE

Created on 2020-11-30 by the reprex package (v0.3.0)

Ok. Got it.
str_detect(txt, regex("New York(?!.*taxi)"))

1 Like

I was just about to suggest

str_detect(txt," taxi") == FALSE

because some days lack sufficient hours to deal with regex

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.