w/nocase
sre ...)Enclosed sres are case-insensitive. In a Unicode context character and string literals match with the default simple Unicode case-insensitive matching. Implementations may, but are not required to, handle variable length case conversions, such as #\x00DF "ß" matching the two characters "SS".
Character sets match if any character in the set matches case-insensitively to the input. Conceptually each cset-sre
is expanded to contain all case variants for all of its characters. In a compound cset-sre
the expansion is applied at the terminals consisting of characters, strings, embedded SRFI 14 char-sets, and named character sets. For simple unions this would be equivalent to computing the full union first and then expanding case variants, but the semantics can differ when differences and intersections are applied. For example, (w/nocase (~ ("Aab")))
is equivalent to (~ ("AaBb"))
, for which "B" is clearly not a member. However if you were to compute (~ ("Aab"))
first then you would have a char-set containing "B", and after expanding case variants both "B" and "b" would be members.
In an ASCII context only the 52 ASCII letters (/ "a-zA-Z")
match case-insensitively to each other.
In a Unicode context the only named cset-sre
which are affected by w/nocase
are upper
and lower
. Note that the case insensitive versions of these are not equivalent to letter
as there are characters with the letter property but no case.
(regexp-search "needle" "haynEEdlehay") => #f (regexp-search '(w/nocase "needle") "haynEEdlehay") => #<regexp-match> (regexp-search '(~ ("Aab")) "B") => #<regexp-match> (regexp-search '(~ ("Aab")) "b") => #f (regexp-search '(w/nocase (~ ("Aab"))) "B") => #<regexp-match> (regexp-search '(w/nocase (~ ("Aab"))) "b") => #<regexp-match> (regexp-search '(~ (w/nocase ("Aab"))) "B") => #<regexp-match> (regexp-search '(~ (w/nocase ("Aab"))) "b") => #<regexp-match>