Your first solution breaks with the string 'xnox' (which should not produce any output as there are no characters residing between two x'es), it just displays 'nx' which is undesired. Your second solution suffers from the same problem. Whenever there are alternating x's and other chars (even x's as well) your solution is perfect, however it does not take into account that their can be multiple chars between x's. (mind you the original post did not mention this either but it's not unrealistic to assume this)
Well, I already mentioned this in my post (last line).
There is no easy way to solve this, as I said. How would
one now if 'xtxaxix' would mean taxi or tai?