# NOTA: using `string_get` instead of `string_is` may lead to a faster understanding
# of the examples
x = string_vec("One, two, one... two, microphone, check")
# default is regular expression search
# => 3 character items
string_is(x, "^...$")
# to trigger fixed search use the flag 'fixed'
string_is(x, "fixed/...")
# you can just use the first letter
string_is(x, "f/...")
# to negate, use '!' as the first element of the pattern
string_is(x, "f/!...")
# you can combine several patterns with " & " or " | "
string_is(x, "one & c")
string_is(x, "one | c")
#
# word: adds word boundaries
#
# compare
string_is(x, "one")
# with
string_is(x, "w/one")
# words can be chained with commas (it is like an OR logical operation)
string_is(x, "w/one, two")
# compare with
string_is(x, "w/one & two")
# remember that you can still negate
string_is(x, "w/one & !two")
# you can combine the flags
# compare
string_is(x, "w/one")
# with
string_is(x, "wi/one")
#
# the `magic` flag
#
p = "one"
string_is(x, "m/{p}")
# Explanation:
# - "p" is interpolated into "one"
# - we get the equivalent: string_is(x, "one")
#
# string_which
#
# it works exactly the same way as string_is
# Which are the items containing an 'e' and an 'o'?
string_which(x, "e", "o")
# equivalently
string_which(x, "e & o")
Run the code above in your browser using DataLab