Tag Info

Hot answers tagged

26

Case insensitivity is a property of the comparison, not of the object (*). You'll want to compare the same string independently of the case or not depending on the context. (And you have a whole kind of worms as what is a case insensitive comparison depend on the language -- i is upper cased as İ in Turkish -- and even the context -- depending on the word ...


7

Just off the top of my head: Pros: Makes a lot of code self-documenting, e.g: bool UserIsRegistered(CaseInsensitiveString Username) May streamline comparisons May remove the potential for comparison bugs Cons: Might be a waste of time people can just convert regular strings to lowercase if they need case-insensitive comparisons Using it for ...


7

http://tools.ietf.org/html/rfc5321#page-42 (emphasis added): While the above definition for Local-part is relatively permissive, for maximum interoperability, a host that expects to receive mail SHOULD avoid defining mailboxes where the Local-part requires (or uses) the Quoted-string form or where the Local-part is case-sensitive. The rfc discourages ...


4

What you should be doing is using the email address as provided for sending emails and transforming it into something less error-prone when using it as an account identifier or at least using it as a fallback when you don't find an exact match. This would be a very rough analogue to what the Soundex algorithm does for words or names in English by removing ...


4

Paragraph 2.4. General Syntax Principles and Transaction Model of RFC 5321 states (emphasis mine): Therefore, SMTP implementations MUST take care to preserve the case of mailbox local-parts. In particular, for some hosts, the user "smith" is different from the user "Smith". However, exploiting the case sensitivity of mailbox local-parts impedes ...


4

CaseInsensitiveString is not a bad idea depends on your use, as long as you don't expect it to work together with String. You may convert a CaseInsensitiveString to a String, or vice-versa, and that's all you should do. Problem will happen if you try to do something like class CaseInsensitiveString { private String value; public boolean equals(Object ...


2

However if regex is case insensitive alphabetic characters do have a special meaning of "this character or same character in opposite case" and such special meaning is not ignored in \x sequences. You're reading too much into what constitutes "special meaning." In this case, it refers to single characters that direct interpretation of the input ...


2

Explicitly creating types in your domain/model is very good practice. Like Maxpm said it is self documenting. Also a big plus: people can't (by accident) use wrong input. The only negative thing it has would be that it will scare off junior (and even some medior) programmers.


1

A CaseInsensitiveString class and its helpers add a lot of code and they will make everything less readable than the String.toLoweCase() method. CaseInsensitiveString vaName1 = new CaseInsensitiveString('HeLLo'); //... a lot of lines here CaseInsensitiveString vaName2 = new CaseInsensitiveString('Hello'); //... a lot of lines here if ...



Only top voted, non community-wiki answers of a minimum length are eligible