Counting the number of specific characters in a string in velocity script for email
I'm building a html email and in a token I have a string field which has a list of up to 7 phone numbers in it, each phone number separated by a comma, e.g:
01234567, 01234567, 01234567, 01234567
I need to be able to replace the last comma in the string with ' and' instead of the comma. What would be the best way of doing it?