Dave's Brain

Browse - Programming Tips - Have can I compare two strings without being sensitive to case?

Date: 2015nov20
Language: javaScript
Keywords: insensitive, ignore, equalsIgnoreCase

Q.  Have can I compare two strings without being sensitive to case?

A.

function ceq(a, b) { return a.toLowerCase() == b.toLowerCase(); }
Example use:
if (ceq('aPPle', 'Apple')) { alert('They are the same'); } else { alert('They are the different'); }

Add a comment

Sign in to add a comment
Copyright © 2008-2017, dave - Code samples on Dave's Brain is licensed under the Creative Commons Attribution 2.5 License. However other material, including English text has all rights reserved.