String (String fieldText) { if (!myPatternForEntireText.matcher(fieldText).matches()) { return JavaStartersBundle.message("message.only.latin.characters.digits.and.some.other.symbols.are.allowed.here"); } char firstSymbol = fieldText.charAt(0); char lastSymbol = fieldText.charAt(fieldText.length() - 1); if (firstSymbol == '.' || lastSymbol == '.') { return JavaStartersBundle.message("message.must.not.start.or.end.with.dot"); } if (fieldText.contains("..")) { return JavaStartersBundle.message("message.must.not.contain.double.dot.sequences"); } String[] wordsBetweenDots = fieldText.split("\\."); for (String word : wordsBetweenDots) { if (!myPatternForOneWord.matcher(word).matches()) { return JavaStartersBundle.message("message.part.is.incorrect.and.must.start.with.latin.character.or.some.other.symbols", word); } } return null; }