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
SalesRedSalesRed 

Equivalent String Function to charAt() ?

Hello,

 

I was wondering if there is any equivalent string function that can used similar to the charAt function which exists in java?

I know no such method is listed at http://www.salesforce.com/us/developer/docs/apexcode/Content/apex_methods_system_string.htm

 

I know it's possible to look through the string and to get each character using the substring function in such a loop but it would be much better if a function existed similar to charAt.

 

if anyone knows of a better way of doing this you can let me know.

 

Thanks!

Best Answer chosen by Admin (Salesforce Developers) 
Platy ITPlaty IT

You can use substring the same way you would charAt, it doesn't have to be in a loop.  If you know exactly which character(s) you're trying to grab, substring just requires 2 inputs to get it, the start and end position.  So...

 

charAt(4) is the same as substring(3,4)

All Answers

Platy ITPlaty IT

You can use substring the same way you would charAt, it doesn't have to be in a loop.  If you know exactly which character(s) you're trying to grab, substring just requires 2 inputs to get it, the start and end position.  So...

 

charAt(4) is the same as substring(3,4)

This was selected as the best answer
keniam cresti 5keniam cresti 5
Thanks for sharing this valuable info. TalkToSonic Survey 
bobby brownbobby brown
very good information thank you My name is Bobby, and I'm a music enthusiast and Spotify power user who's passionate about sharing my knowledge and expertise with fellow music lovers.

Join me on this musical journey as I provide comprehensive, step-by-step tutorials on Spotify's features, tips to enhance your music listening experience, and recommendations for playlists and artists tailored to your taste. Whether you're a new user or a long-time subscriber, there's always something to learn and discover.

Visit:https://howtousespotify.com/