try {
int nStartFlags = com.sun.star.i18n.KParseTokens.ANY_LETTER_OR_NUMBER + com.sun.star.i18n.KParseTokens.ASC_UNDERSCORE;
int nContFlags = nStartFlags;
Object ocharservice = _xMSF.createInstance("com.sun.star.i18n.CharacterClassification");
XCharacterClassification xCharacterClassification = (XCharacterClassification) UnoRuntime.queryInterface(XCharacterClassification.class, ocharservice);
ParseResult aResult = xCharacterClassification.parsePredefinedToken(KParseType.IDENTNAME, _sString, 0, _aLocale, nStartFlags, "", nContFlags, " ");
return aResult.EndPos;
} catch (Exception e) {
e.printStackTrace(System.out);
return -1;
}}