Example usage for java.lang String replaceFirst

List of usage examples for java.lang String replaceFirst

Introduction

In this page you can find the example usage for java.lang String replaceFirst.

Prototype

public String replaceFirst(String regex, String replacement) 

Source Link

Document

Replaces the first substring of this string that matches the given regular expression with the given replacement.

Usage

From source file:com.shazam.fork.summary.HtmlConverters.java

private static String prettifyMethodName(String testMethod) {
    testMethod = testMethod.replaceFirst("test", "").replaceAll("_", ", ")
            .replaceAll("(\\p{Ll})(\\p{Lu})", "$1 $2").replaceAll("(\\p{Lu})(\\p{Lu})", "$1 $2");
    return capitalizeFully(testMethod);
}

From source file:Main.java

public static List<String> getAllTables(Uri uri) {
    List<String> result = new ArrayList<String>();

    String mainTable = uri.getLastPathSegment();
    result.add(mainTable);//from  w w  w .  j  av  a  2  s  .c  o m

    Set<String> queryParameterNames = getQueryParameterNames(uri);
    Iterator<String> iterator = queryParameterNames.iterator();
    while (iterator.hasNext()) {
        String table = iterator.next();
        if (table.startsWith(TABLE)) {
            result.add(table.replaceFirst(TABLE, ""));
        }
    }
    return result;
}

From source file:com.m3.methodcache.interceptor.AbstractCacheResultInterceptor.java

/**
 * Removes S2AOP enhancement/*www.  j  a v a 2  s.  co  m*/
 *
 * @param canonicalName canonical name
 * @return raw class name
 * @see "http://www.seasar.org/en/"
 */
protected static String getClassNameWithoutS2AOP(String canonicalName) {
    return canonicalName.replaceFirst("\\$\\$EnhancedByS2AOP\\$\\$.+", "");
}

From source file:com.gopivotal.cloudfoundry.test.support.util.JdbcUrlNormalizer.java

/**
 * Normalize a JDBC URL to account for differences in underlying implementations when testing.  The normalization
 * algorithm includes removing the {@literal jdbc} prefix and any query parameters, leaving the core part of the URL
 * (i.e. scheme, host, port, and path).// www . j  a  va2 s.c  o  m
 *
 * @param raw the raw URL
 *
 * @return a normalized URL
 */
public static URI normalize(String raw) {
    String modified = raw;

    if (modified.startsWith("jdbc:")) {
        modified = modified.replaceFirst("jdbc:", "");
    }

    if (modified.startsWith("postgres:")) {
        modified = modified.replaceFirst("postgres:", "postgresql:");
    }

    if (modified.contains("@")) {
        modified = modified.replaceFirst("/[^/@]*@", "/");
    }

    if (modified.contains("?")) {
        modified = modified.substring(0, modified.indexOf('?'));
    }

    return URI.create(modified);
}

From source file:de.blizzy.documentr.system.Version.java

static Version fromString(String s) {
    Assert.isTrue(s.matches("^[0-9]+\\.[0-9]+\\.[0-9]+(-.+)?$")); //$NON-NLS-1$

    s = s.replaceFirst("-.*$", StringUtils.EMPTY); //$NON-NLS-1$
    String[] parts = s.split("\\."); //$NON-NLS-1$
    return new Version(Integer.parseInt(parts[0]), Integer.parseInt(parts[1]), Integer.parseInt(parts[2]));
}

From source file:com.ibm.watson.developer_cloud.util.RequestUtil.java

/**
 * Replace the url endpoint (schema + host + port) with the given end point.
 * //from  w  w  w  .ja  v  a  2s . c  o  m
 * @param url the url to update
 * @param endPoint the end point
 * @return the new url
 */
public static String replaceEndPoint(String url, String endPoint) {
    return endPoint + url.replaceFirst(DEFAULT_ENDPOINT, "");
}

From source file:com.intuit.tank.vm.common.util.ValidationUtil.java

private static final String removeIdentifier(String key, char c) {
    if (key.charAt(0) == c) {
        key = key.replaceFirst(Character.toString(c), "");
    }//from  w  ww.j a v a 2s.c  om
    return key;
}

From source file:com.datatorrent.stram.client.WebServicesVersionConversion.java

public static Converter getConverter(String version) throws IncompatibleVersionException {
    if (!isVersionCompatible(version)) {
        throw new IncompatibleVersionException("Stram version " + version
                + " is incompatible with the current build (" + WebServices.VERSION + ")");
    }//from w  w w .  java 2 s .c o m
    // Add old versions that ARE supported here in the future
    if (version.equals("v1")) {
        return new Converter() {

            @Override
            public String convertCommandPath(String path) {
                return path.replaceFirst("/ws/v2/", "/ws/v1/");
            }

            @Override
            public String convertResponse(String path, String response) {
                return response;
            }
        };
    }
    return null;
}

From source file:la.alsocan.jsonshapeshifter.bindings.AbstractNodeBinding.java

static String jsonPointer(String schemaPointer, List<Integer> context) {
    for (Integer index : context) {
        schemaPointer = schemaPointer.replaceFirst(PATH_DELIMITER_REGEX, String.valueOf(index));
    }//from  w ww.  ja v a 2s  . c o m
    return schemaPointer;
}

From source file:annis.test.TestHelper.java

private static String packagePath(Class<?> clazz) {
    String packageDeclaration = clazz.getPackage().toString();
    String path = packageDeclaration.replaceFirst("package ", "").replaceAll("\\.", "/") + "/";
    return path;//from   w ww  . j a v a 2s. c  o m
}