Thank you very much! I just began learning regular expressions so I was avoiding it ^^;. | [reply] |
It's hard to learn something by avoiding it!
| [reply] |
Though it's a good attempt, I'm not too impressed.
- If the requirements change from 1 letter to more, your code won't handle it.
- Your right hand side for the substitution is uglier than it should be.
My proposed fix:
$combined =~ s/([a-z]+)(\d+)/\U$1:$2/i;
| [reply] [d/l] |
"If the requirements change from 1 letter to more, your code won't handle it. "
If the requirements change from letters to kanji or hiragana characters, *your code* won't handle it either. And that is just as likely.
Coding now to exceed the known requirements, in order to cater for some future, speculative change, is a waste of time and effort.
When (if!) the requirements change, the the code can be changed to match the new requirements.
| [reply] |