Additionally, I would assume that this code below should also work ( currently throws an exception!! )
can you post the source as a trycf gist?
the switch() must evaluate to true or 1 otherwise its pointless. The idea is that the regex will return true or false. In this particular case the regex returns the position which is 1, so true also works
But generally speaking if the regex is written differently the switch statement must react to true value only
if that makes sense.