Check if an input is numeric or not

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

https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/apex_methods_system_string.htm

Methods of interest are:

  1. isAlpha()
  2. isAlphanumeric()
  3. isNumeric()

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 :

  • isNumeric
  • isAlpha
  • String Instance methods

isNumeric()

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

isAlpha()

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