Hello Everyone, In this tutorial we are going to learn about a apex function that removes leading zeros(0) from a alphanumeric text. Here i will show you a code example that makes this more understandable to all of you. So let's start,
Remove leading zeros from alphanumeric text using apex
The string replaceFirst() method used to remove leading zeros from alphanumeric text, It's uses regular expression to find and replace the substring with replacement substring argument.
Syntex:
String.replaceFirst('^0+', '');
OR
String.replaceFirst('^0+(?!$)', '');
Example:
Output:
Hope you like this post, for any query or suggestions please feel free to comment.
Thank you.
2 Comments
Nice post really helpful
ReplyDeleteThank you so much..!
DeletePost a Comment