in reply to Best way to put : between fields in a string
To be honest, a description of what your cow-orker wants would be helpful, too. I prefer to write my solution in the language of the problem, rather than the language of the solution. It makes things more obvious later (and possibly, more robust when strange things happen).
For example, if you were to say that "Each set of letters followed by set of numbers is a token, and we want colons to separate our tokens," then, IMO, splitting the string into said tokens, and joining with a colon, as you did, seems to be the best way to me to do it.
But, if the requirement is, "I don't want numbers and letters to touch when the number is prior to the letter, so separate them with a colon," then I would suggest an alternate approach, such as s/(?<\d)(?>[[:alpha:]])/:/g.
The point is to really pay attention to what you really need, and to write the solution that matches.
|
|---|