should RegexBuilder::case_sensitive(false)
be added as an alias for RegexBuilder::case_insensitive(true)
?
#1209
-
Would it make sense to perhaps add a separate function to configure the case sensitivity of a regex? Related blog: https://testing.googleblog.com/2023/10/improve-readability-with-positive.html |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
If I were starting over, I might be inclined to use But as for now, no, I actually think having both is worse than having one. When you have both, folks start wondering what the difference is between them and which one they should use. |
Beta Was this translation helpful? Give feedback.
If I were starting over, I might be inclined to use
case_sensitive
rather thancase_insensitive
. However, crucially, the actual regex flag isi
, which means "opt into case insensitive matching." In this way,RegexBuilder
is matching the conceptualization prompted by the syntax. And changing thei
to something else is a much more difficult change. For example, since case sensitive matching is generally expected to be enabled by default, it would imply doing something like(?-X)
(whereX
is the flag that means "enable case sensitive matching") to get case insensitive matching.But as for now, no, I actually think having both is worse than having one. When you have both, folks start wonderin…