StringHelper { public static String getLoginFromFormattedNameAndLogin(String formattedNameAndLogin){ if (formattedNameAndLogin == null || formattedNameAndLogin.isEmpty()){ return ""; } Pattern userLoginRegexPattern = Pattern.compile("^.*?\\(?([-\\w+]+)\\)?$"); Matcher matchLoginRegex = userLoginRegexPattern.matcher(formattedNameAndLogin.trim()); String userLogin = ""; if (matchLoginRegex.find()) userLogin = matchLoginRegex.group(1); return userLogin; }  static String trimAndRemoveExtraSpacesBetweenWords(String sParam); static String removeExtraSpacesAndCapOnlyFirstLetterOfEachWord(String sParam); static String removeExtraSpacesAndCapFirstLetter(String sParam); static String getLoginFromFormattedNameAndLogin(String formattedNameAndLogin); static boolean isStringAValidEmailAddress(String s); static Integer convertStringToInteger(String s); static String toCamelCase(String s); static String deCamelCase(String s);  }
@Test (groups = "unit-tests") public void testGetLoginFromFormattedNameAndLogin() { String expected = "Test"; Assert.assertEquals(StringHelper.getLoginFromFormattedNameAndLogin("This is a (Test)"), expected); }