One can use StringMatchQ
to test whether a string matches a string pattern. One can use the IgnoreCase
option of StringMatchQ
to ignore case when comparing the string and the string pattern:
StringMatchQ["Apple", "Apple"]StringMatchQ["Apple", "apple"]StringMatchQ["Apple", "apple", IgnoreCase -> True](* `True *)(* `False` *)(* `True` *)
How can I include the directive to "ignore case" directly within the string pattern or StringExpression
-- rather than using the IgnoreCase
option? I have found the function CaseSensitive
, which takes a string pattern as input and returns a case-sensitive string pattern:
StringMatchQ["Apple", StringExpression["Apple"]]StringMatchQ["Apple", StringExpression["apple"]]StringMatchQ["Apple", StringExpression["apple"], IgnoreCase -> True]StringMatchQ["Apple", StringExpression[CaseSensitive["Apple"]]]StringMatchQ["Apple", StringExpression[CaseSensitive["apple"]]]StringMatchQ["Apple", StringExpression[CaseSensitive["apple"]], IgnoreCase -> True](* `True` *)(* `False` *)(* `True` *)(* `True` *)(* `False` *)(* `False` *)
Is there a way to somehow "negate"CaseSensitive
so that the string pattern specifies string insensitivity?