Thanks Roger for your wonderful inisght and leading me towards the correct
solution. It had got me thinking in the right direction until Nate served it out
to me in a golden platter.
Thanks all for the wonderful help. Much appreciate it.
It might only be a silver platter depending on what happens next. If a subtle
bug shows up, will you be able to debug and solve it?
Sometimes it’s better to go with a not-quite-so-elegant solution in order to
resolve any issues later… or even make changes to it.
I am totally green on regular expressions so I don’t know if Nate’s solution
is perfect or if it’ll choke on some special character in a different data
format – like French characters.
How about if a change is required and the business rules want a second character
ignored in the selection?
Ultimately, it’s up to you to test the solution against the data you’re
providing the solution for.
A developer should always know what will happen to his code when any value is
passed in to it. Either the value is expected and handled properly, or the value
is invalid and should be trapped in an appropriate exception mechanism.