I have a string containing either “0123456789 ?”. I would like to
- if first char is not ' ' or '?' and the rest is " ", return the first char
- if last char is not ' ' or '?' and the rest is " ", return the last char
- if the string is only " ", return -1
- and else, return -2
I found several solutions but none of them satisfy me in term of speed and nice coding.
Could someone that think of a nice and elegant solution, share it to me ?!
Thank You
what about this?