How to get last 10 numbers from a String using Apex in Salesforce ?

We believe in growing together ! Forums Superbadges Help and Discussions How to get last 10 numbers from a String using Apex in Salesforce ?

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • #1437 Reply
    Admin
    Keymaster

    How to get last 10 numbers from a String using Apex in Salesforce to get a valid ten digit number and also add +91?

    #1438 Reply
    Admin
    Keymaster

    We can use right(n) command to get last n digits from a String using Apex.

    Syntax:
    str.right(n);

    Example:
    String strphoneNumber = ‘917718838553’;
    string phnumber = strphoneNumber.right(10);
    string phonewithCode = ’91’+strphoneNumber.right(10);

Viewing 2 posts - 1 through 2 (of 2 total)
Reply To: Reply #1438 in How to get last 10 numbers from a String using Apex in Salesforce ?
Your information:




error: Content is protected !!