I would probably consider doing this another way…
Have an empty hashmap<String sub, int multiplier>
Read in the name
Generate the subname
Fetch from or create subname in hashmap
If new, set multiplier to 1
If exists, increment multiplier
Return String.format(ā%s%3dā, subname, multiplier x 5).toUpperCase()
I would give you code but writing the above was hard enough on an iPad ?
solved Keep track of string matches to create a new ID