find a single char in a string
<p>I have a string containing either "0123456789 ?". I would like to</p>

<pre><code>- 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
</code></pre>

<p>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 ?!</p>

<p>Thank You</p>
