/** * <p>Search a String to find the first index of any * character in the given set of characters.</p> * * <p>A <code>null</code> String will return <code>-1</code>. * A <code>null</code> search string will return <code>-1</code>.</p> * * <pre> * StringUtils.indexOfAny(null, *) = -1 * StringUtils.indexOfAny("", *) = -1 * StringUtils.indexOfAny(*, null) = -1 * StringUtils.indexOfAny(*, "") = -1 * StringUtils.indexOfAny("zzabyycdxx", "za") = 0 * StringUtils.indexOfAny("zzabyycdxx", "by") = 3 * StringUtils.indexOfAny("aba","z") = -1 * </pre> * * @param str the String to check, may be null * @param searchChars the chars to search for, may be null * @return the index of any of the chars, -1 if no match or null input * @since 2.0 */ public static int indexOfAny(String str, String searchChars) { if (isEmpty(str) || isEmpty(searchChars)) { return INDEX_NOT_FOUND; } return indexOfAny(str, searchChars.toCharArray()); }
private boolean hasNumberAnywhere( String version ) { return StringUtils.indexOfAny( version, NUMS ) != ( -1 ); }
/** * Finds the first index of a special character within the given string * after a start position. * * @param string * the string to check * @param startPos * the position to start from * @return the first index of a special character */ private static int indexOfAnySpecChar(String string, int startPos) { return StringUtils.indexOfAny(string.substring(startPos), specialChars); }
String getJarVersion(String jarName) { int indexOfAny = StringUtils.indexOfAny(jarName, NUMBERS); int jarIndex = jarName.indexOf(".jar"); if (jarIndex == -1) { jarIndex = jarName.indexOf(".zip"); } if (indexOfAny != -1 && jarIndex != -1) { return jarName.substring(indexOfAny+1, jarIndex); } return ""; }
String getArtifactId(String jarName) { int indexOfAny = StringUtils.indexOfAny(jarName, NUMBERS); if (indexOfAny != -1) { return jarName.substring(0, indexOfAny); } else { int dotIndex = jarName.indexOf("."); if(dotIndex != -1){ return jarName.substring(0, dotIndex); } return jarName; } }
/** * Tries to find the index of the separator character in the given string. * This method checks for the presence of separator characters in the given * string. If multiple characters are found, the first one is assumed to be * the correct separator. If there are quoting characters, they are taken * into account, too. * * @param line the line to be checked * @return the index of the separator character or -1 if none is found */ private int findSeparator(String line) { int index = findSeparatorBeforeQuote(line, StringUtils.indexOfAny(line, QUOTE_CHARACTERS)); if (index < 0) { index = StringUtils.indexOfAny(line, SEPARATOR_CHARS); } return index; }
/** * Obtains the query string to use for reloading the current page.<br> * Unwanted parameters are removed. * @return */ public String currentQueryString() { String s = request.getQueryString(); s = "&" + s; int p1; while ((p1 = StringUtils.indexOfAny(s, new String[]{"&type=", "&command=", "&page=" })) != -1) { int p2 = s.indexOf('&', p1 + 1); s = s.substring(0, p1) + (p2 != -1 ? s.substring(p2) : StringUtils.EMPTY); } return s.substring(1); }
/** * <p>Search a String to find the first index of any * character in the given set of characters.</p> * * <p>A <code>null</code> String will return <code>-1</code>. * A <code>null</code> search string will return <code>-1</code>.</p> * * <pre> * StringUtils.indexOfAny(null, *) = -1 * StringUtils.indexOfAny("", *) = -1 * StringUtils.indexOfAny(*, null) = -1 * StringUtils.indexOfAny(*, "") = -1 * StringUtils.indexOfAny("zzabyycdxx", "za") = 0 * StringUtils.indexOfAny("zzabyycdxx", "by") = 3 * StringUtils.indexOfAny("aba","z") = -1 * </pre> * * @param str the String to check, may be null * @param searchChars the chars to search for, may be null * @return the index of any of the chars, -1 if no match or null input * @since 2.0 */ public static int indexOfAny(String str, String searchChars) { if (isEmpty(str) || isEmpty(searchChars)) { return -1; } return indexOfAny(str, searchChars.toCharArray()); }
/** * <p>Search a String to find the first index of any * character in the given set of characters.</p> * * <p>A <code>null</code> String will return <code>-1</code>. * A <code>null</code> search string will return <code>-1</code>.</p> * * <pre> * StringUtils.indexOfAny(null, *) = -1 * StringUtils.indexOfAny("", *) = -1 * StringUtils.indexOfAny(*, null) = -1 * StringUtils.indexOfAny(*, "") = -1 * StringUtils.indexOfAny("zzabyycdxx", "za") = 0 * StringUtils.indexOfAny("zzabyycdxx", "by") = 3 * StringUtils.indexOfAny("aba","z") = -1 * </pre> * * @param str the String to check, may be null * @param searchChars the chars to search for, may be null * @return the index of any of the chars, -1 if no match or null input * @since 2.0 */ public static int indexOfAny(String str, String searchChars) { if (isEmpty(str) || isEmpty(searchChars)) { return INDEX_NOT_FOUND; } return indexOfAny(str, searchChars.toCharArray()); }
/** * <p>Search a String to find the first index of any * character in the given set of characters.</p> * * <p>A <code>null</code> String will return <code>-1</code>. * A <code>null</code> search string will return <code>-1</code>.</p> * * <pre> * StringUtils.indexOfAny(null, *) = -1 * StringUtils.indexOfAny("", *) = -1 * StringUtils.indexOfAny(*, null) = -1 * StringUtils.indexOfAny(*, "") = -1 * StringUtils.indexOfAny("zzabyycdxx", "za") = 0 * StringUtils.indexOfAny("zzabyycdxx", "by") = 3 * StringUtils.indexOfAny("aba","z") = -1 * </pre> * * @param str the String to check, may be null * @param searchChars the chars to search for, may be null * @return the index of any of the chars, -1 if no match or null input * @since 2.0 */ public static int indexOfAny(String str, String searchChars) { if (isEmpty(str) || isEmpty(searchChars)) { return INDEX_NOT_FOUND; } return indexOfAny(str, searchChars.toCharArray()); }
/** * <p>Search a String to find the first index of any * character in the given set of characters.</p> * * <p>A <code>null</code> String will return <code>-1</code>. * A <code>null</code> search string will return <code>-1</code>.</p> * * <pre> * StringUtils.indexOfAny(null, *) = -1 * StringUtils.indexOfAny("", *) = -1 * StringUtils.indexOfAny(*, null) = -1 * StringUtils.indexOfAny(*, "") = -1 * StringUtils.indexOfAny("zzabyycdxx", "za") = 0 * StringUtils.indexOfAny("zzabyycdxx", "by") = 3 * StringUtils.indexOfAny("aba","z") = -1 * </pre> * * @param str the String to check, may be null * @param searchChars the chars to search for, may be null * @return the index of any of the chars, -1 if no match or null input * @since 2.0 */ public static int indexOfAny(String str, String searchChars) { if (isEmpty(str) || isEmpty(searchChars)) { return INDEX_NOT_FOUND; } return indexOfAny(str, searchChars.toCharArray()); }
/** * <p>Search a String to find the first index of any * character in the given set of characters.</p> * * <p>A <code>null</code> String will return <code>-1</code>. * A <code>null</code> search string will return <code>-1</code>.</p> * * <pre> * StringUtils.indexOfAny(null, *) = -1 * StringUtils.indexOfAny("", *) = -1 * StringUtils.indexOfAny(*, null) = -1 * StringUtils.indexOfAny(*, "") = -1 * StringUtils.indexOfAny("zzabyycdxx", "za") = 0 * StringUtils.indexOfAny("zzabyycdxx", "by") = 3 * StringUtils.indexOfAny("aba","z") = -1 * </pre> * * @param str the String to check, may be null * @param searchChars the chars to search for, may be null * @return the index of any of the chars, -1 if no match or null input * @since 2.0 */ public static int indexOfAny(String str, String searchChars) { if (isEmpty(str) || isEmpty(searchChars)) { return -1; } return indexOfAny(str, searchChars.toCharArray()); }
public static Locale parseLocale(String locale, String variant) { Locale ret = null; String language = locale; String country = null; int index = StringUtils.indexOfAny(locale, "-_"); if (index > -1) { language = locale.substring(0, index); country = locale.substring(index + 1); } if (StringUtils.isEmpty(language)) { throw new IllegalArgumentException("No language in locale"); } if (country == null) { ret = variant != null ? new Locale(language, "", variant) : new Locale(language, ""); } else if (country.length() > 0) { ret = variant != null ? new Locale(language, country, variant) : new Locale(language, country); } else { throw new IllegalArgumentException("Empty country in locale"); } return ret; }
public static EnvType getEnvType(String env) { String[] sandboxEnvs = new String[]{"verify", "preview", "sandbox", "stable", "adeng"}; if (env.contains("prod")) { return EnvType.PROD; } else if (StringUtils.indexOfAny(env, sandboxEnvs) != -1) { return EnvType.SANDBOX; } else if (env.contains("dev")) { return EnvType.DEV; } return EnvType.PROD; }
value.indexOf(exceptions[0]) : StringUtils.indexOfAny(value, exceptions); rem.indexOf(exceptions[0]) : StringUtils.indexOfAny(rem, exceptions); } while (nextExceptionIndex >= 0); result.append(rem.toUpperCase(t.getLocale()));
public Command(final String raw) { this.raw = StringUtils.stripToEmpty(raw); String opWithPunctuation = StringUtils.stripToEmpty(StringUtils.lowerCase(StringUtils.substringBefore(this.raw, " "))); int punctuationIndex = StringUtils.indexOfAny(opWithPunctuation, PUNCTUATIONS); if(punctuationIndex > 0) { this.punctuation = StringUtils.substring(opWithPunctuation, punctuationIndex).split("(?!^)"); this.operation = StringUtils.substring(opWithPunctuation, 0, punctuationIndex); } else { this.punctuation = new String[]{}; this.operation = opWithPunctuation; } this.param = StringUtils.stripToEmpty(StringUtils.removeStart(this.raw, opWithPunctuation)); this.params = StringUtils.split(this.param); if(log.isTraceEnabled()) { log.trace("Raw: {}", this.raw); log.trace("Operation: {}", this.operation); log.trace("Punctuation: {}", Arrays.toString(this.punctuation)); log.trace("Param: {}", this.param); log.trace("Params: {}", Arrays.toString(this.params)); } }
public Command(final String raw) { this.raw = StringUtils.stripToEmpty(raw); String opWithPunctuation = StringUtils.stripToEmpty(StringUtils.lowerCase(StringUtils.substringBefore(this.raw, " "))); int punctuationIndex = StringUtils.indexOfAny(opWithPunctuation, PUNCTUATIONS); if(punctuationIndex > 0) { this.punctuation = StringUtils.substring(opWithPunctuation, punctuationIndex).split("(?!^)"); this.operation = StringUtils.substring(opWithPunctuation, 0, punctuationIndex); } else { this.punctuation = new String[]{}; this.operation = opWithPunctuation; } this.param = StringUtils.stripToEmpty(StringUtils.removeStart(this.raw, opWithPunctuation)); this.params = StringUtils.split(this.param); if(log.isTraceEnabled()) { log.trace("Raw: {}", this.raw); log.trace("Operation: {}", this.operation); log.trace("Punctuation: {}", Arrays.toString(this.punctuation)); log.trace("Param: {}", this.param); log.trace("Params: {}", Arrays.toString(this.params)); } }
int findAt = StringUtils.indexOfAny(tick, timeChars); // needs commons lang version 2
/** * In a completion like "$abc<caret> def" the element is a word psi lead element, in this case to not expand the autocompletion after the whitespace character * https://code.google.com/p/bashsupport/issues/detail?id=51 * a completion at the end of a line with an open string is parsed as string until the first quote in the next line(s) * in the case of a newline character in the string the end offset is set to the end of the string to avoid aggressive string replacements */ private boolean fixReplacementOffsetInString(PsiElement element, OffsetMap offsetMap) { int endCharIndex = StringUtils.indexOfAny(element.getText(), new char[]{'\n', ' '}); if (endCharIndex > 0) { offsetMap.addOffset(IDENTIFIER_END_OFFSET, element.getTextOffset() + endCharIndex); return true; } return false; } }
if (StringUtils.indexOfAny(sqlExpression, FUNCTION_DELIMITERS) != -1) int endIndex = StringUtils.indexOfAny(post, FUNCTION_DELIMITERS); if (endIndex < 0)