How do I do a case-insensitive string comparison?
Assuming ASCII strings: As of Python 3.3, casefold() is a better alternative: If you want a more comprehensive solution that handles more complex unicode comparisons, see other answers.
Assuming ASCII strings: As of Python 3.3, casefold() is a better alternative: If you want a more comprehensive solution that handles more complex unicode comparisons, see other answers.
You can use the localeCompare() method.
It’s easy enough to write your own comparison function: Or inline (c/o Marco Demaio):
cmp arg2, arg1 performs the same operation as sub arg2, arg1 except that none of the operands are modified. The difference is not stored anywhere. However, the flags register is updated and can be used in a conditional jump, like jump-if-equal (JE), most often as the next instruction after the cmp. The advantage over other … Read more