So I was wondering how possible it is to reformat a single string in a specific way with dashes depending on the number and letter combination positions. I'm working on a script for a game that handles license plates but it does not add dashes. I would like to format the string on the basis of numbers and letters the way License Plates are handled in the Netherlands. For example
if the license plate is 91FKTG it will format it to 91-FK-TG, if the plate is GB000T it will reformat to GB-000-T.
So the formatting would have to be done on how it detects the combination. Current combinations are
9 = number obviously, X = letter
- 99-XX-XX
- 99-XXX-9
- 9-XXX-99
- XX-999-X
- X-999-XX
How would I go around detecting it in LUA, and have it properly dash based on what it detects? Is it even doable?
I have no idea on how to approach this as I'm still a novice in LUA. Any help would be appreciated
We can apply templates to each element in the loop. The
gsubfunction can also capture values in the template itself. This will help us. Read more here..results:
Templates will be applied to each line 5 times. If no template is found, then
gsubwill not change anything in the line, so the first matching template will change the line as needed