String Class Methods in Salesforce Apex

The String class in Apex is Salesforce’s built-in class for working with text, with methods such as contains(), substring(), split(), replace() and trim(). Instance methods are called on a String variable (name.trim()), and static methods are called on the class itself (String.isBlank(name)).

I ran every method in this tutorial as anonymous Apex in a Salesforce Developer Edition org, including the cases that surprise people: == ignoring case, split('.') returning an empty list, and calling a method on a null String. The real output is shown below, grouped by the job you need to do.

This Tutorial Covers: