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

In our email to case functionality, we plan to introduce a feature via which the users will be able to input the Legacy Account Id which is numeric along with the Salesforce Account Id which is alphanumeric.

Is there any method available in Saleforce library that can indicate whether the data is a string or number ?

share|improve this question
up vote 5 down vote accepted

Yes. The Salesforce dev guide has a bunch of String methods for this kind of stuff.

Methods of interest are:

  1. isAlpha()
  2. isAlphanumeric()
  3. isNumeric()
share|improve this answer

The String class had isNumeric(), isAlpha() and a number of other methods for checking the contents of Strings added in Winter '13.

The documentation for these methods can be found here :


Returns true if the current String contains only Unicode digits; otherwise, returns false.


Returns true if all characters in the current String are Unicode letters only; otherwise, returns false.

Example usage:

String num = '123';
System.debug(num.isNumeric()); // Writes TRUE to the debug log
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.