Salesforce Stack Exchange is a question and answer site for Salesforce administrators, implementation experts, developers and anybody in-between. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

When i tried to run the following code snippet anonymously in dev console i got different boolean results. Is string method startsWith(String) case-sensitive or not?

String s1 = 'Thomas Inc';

It returns false when i changed some letters to upper case. Do i have to convert the source and the comparison string to any of the cases before comparing? Do we have case-insensitive version of this method? Please advice.

share|improve this question
up vote 7 down vote accepted

The String.startsWith method is case sensitive.

However there is a String.startsWithIgnoreCase method which as the name notes is case insensitive.

share|improve this answer
Hmmmm didn't realize this. I googled salesforce string methods. Came to the page and it has a lot less...… – dphil Jul 30 '14 at 2:29
@dphil those are the docs for's release, which was APIv25. I don't know why that's the top result for apex docs but it's a pretty old copy of them at this point. – ca_peterson Jul 30 '14 at 5:02

Your best bet is doing something like:

String s1 = 'Thomas Inc';
share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.