function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion

extracting a single digit form a string

Hello, There must be a simple solution, bit somehow I can't get it. To check validity on a dutch bank account (text string) I need to extract al the chars in the account and do some sort of formula on it. How do I extract say the 3rd char. from a string. Now I use VALUE(RIGHT(LEFT(String__c,3),1)). Get all char upto 3rd form the start of a text string and than get the 1st char from the end. Than with Value I change it to a number. In this case the formula gets to long ( I need to do this 9 times and than add other logic) Anybody have an idea how to extract a char from a string in a different way? Thanks Jeroen

Another option would be to use the substring method.


For example,


String testStr = 'testing';

String oneChar = testStr.subString(3,4); //this will return the 3rd character,s, from the testStr variable


More string methods here





Would the substring function help you? stringX.substring(2,3) should give you the third character.  I don't know if that will shorten the code enough, but it is alternative.


'hamburger'.substring(4, 8);
// Returns "urge"
Integer startIndex, String
Integer endIndex
'smiles'.substring(1, 5);
// Returns "mile



Thanks for the reply's.

I was hoping to do this in a normal formula field in a custom object.

.substring is not supported in the formula area.


Thanks again:smileyhappy: