Just to be precise, what you want is for ODK/javaRosa to support the XPath1.0 functions substring-before()
and substring-after()
[see here].
Note, Enketo appears to fully support XPath1.0, so these will in fact work if you deploy your XForm to Enketo (!) Unfortuantely, javaRosa does not, which means you will be prevented from deploying the same form to ODK Aggregate/KoboToolbox/etc, which perform javaRosa-compat verification when you try submit a new form, and will throw an error when it detects unsupported XPath functions in your calculations:
ODK Validate Errors: org.javarosa.core.log.WrappedException: Error evaluating field 'calculation_001': The problem was located in calculate expression for ${calculation_001} XPath evaluation: cannot handle function 'substring-before' ....
If you can somehow live with just Enketo webforms you could probably limp along... but it means living without ODK Collect (at least until these XPath 1.0 functions are added to javaRosa). Or implementing a long if-then-elseif-... , as described above by Andrew.
Disclaimer: I'm not affiliated with Enketo, just an admirer
- Gareth