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.almende.eve.state.redis.RedisState.java

@Override
public Set<String> keySet() {
    final Jedis redis = provider.getInstance();
    Set<String> keys = redis.smembers(getId() + "_" + KEYS);
    provider.returnInstance(redis);/*from  w  w  w  .  j  a  v a  2 s.  co m*/

    final Set<String> cleanKeys = new HashSet<String>();
    for (String key : keys) {
        cleanKeys.add(key.replaceFirst(getId() + "_", ""));
    }
    return cleanKeys;
}

From source file:com.hihframework.core.utils.StringHelpers.java

/**
 * ?.//from w w w .j a  va 2 s . c om
 *
 * @param arg the arg
 * @return the string
 */
public static String fistCapital(String arg) {
    if (arg != null && !arg.trim().equals("")) {
        arg = arg.replaceFirst(String.valueOf(arg.charAt(0)), String.valueOf(arg.charAt(0)).toUpperCase());
    }
    return arg;
}

From source file:org.openmrs.module.yank.web.controller.ProcessController.java

private String renderMessage(List<String> list, String description) {
    if (list.isEmpty())
        return null;

    if (list.size() > LIST_THRESHOLD)
        return description.replaceFirst("\\$count", "" + list.size());

    return Joiner.on("<br/>").join(list);
}

From source file:com.codepine.api.testrail.model.Test.java

/**
 * Add a custom field./*from w  w w.j  a  v  a  2  s. c om*/
 *
 * @param key   the name of the custom field with or without "custom_" prefix
 * @param value the value of the custom field
 * @return test instance for chaining
 */
public Test addCustomField(String key, Object value) {
    if (customFields == null) {
        customFields = new HashMap<>();
    }
    customFields.put(key.replaceFirst(CUSTOM_FIELD_KEY_PREFIX, ""), value);
    return this;
}

From source file:com.chadekin.jadys.commons.expression.SqlExpressionCleaning.java

public default String cleanExpression(String expression) {
    if (StringUtils.isBlank(expression))
        return StringUtils.EMPTY;
    if (expression.startsWith(JadysSqlOperation.AND.toString())) {
        expression = expression.replaceFirst(JadysSqlOperation.AND.toString(), StringUtils.EMPTY);
    } else if (expression.startsWith(JadysSqlOperation.OR.toString())) {
        expression = expression.replaceFirst(JadysSqlOperation.OR.toString(), StringUtils.EMPTY);
    }//  www  . jav  a2  s  .c  o m
    return expression.trim();
}

From source file:by.creepid.docsreporter.context.validation.ReportFieldsValidator.java

private void addSynonyms() {
    Set<Map.Entry<String, Class<?>>> iterEntries = iteratorNames.entrySet();

    List<String> synonymPathes = new ArrayList<>();

    for (Map.Entry<String, Class<?>> entry : iterEntries) {
        List<String> pathes = FieldHelper.getFieldPath(entry.getValue(), modelClass, modelName);

        for (String path : pathes) {
            for (String fieldPath : fieldHierarchy) {
                if (fieldPath.indexOf(path) != -1) {
                    synonymPathes.add(fieldPath.replaceFirst(path, entry.getKey()));
                }/*from w  ww. j a v  a  2 s  . c o  m*/

            }
        }

    }

    fieldHierarchy.addAll(synonymPathes);
}

From source file:com.blackducksoftware.integration.hub.detect.detector.pip.PipInspectorTreeParser.java

private int getLineLevel(final String line) {
    int level = 0;
    String tmpLine = line;
    while (tmpLine.startsWith(INDENTATION)) {
        tmpLine = tmpLine.replaceFirst(INDENTATION, "");
        level++;/*from  www  .  j  a va2 s.c  o  m*/
    }

    return level;
}

From source file:coral.reef.web.ReefController.java

@RequestMapping("/admin/edit")
public String edit(@RequestParam(value = "name") String name,
        @RequestParam(value = "properties", required = false) String properties,
        @RequestParam(value = "basepath", required = false) String basepath, Map<String, Object> model) {

    CoralBean cb = coralBeanRepository.findOne(name);

    if (cb == null) {
        cb = new CoralBean();
        String content;/*from ww  w.ja v  a  2 s . c o  m*/
        try {
            Scanner scan = new Scanner(new ClassPathResource("reef.default.properties").getInputStream());
            scan.useDelimiter("\\Z");
            content = scan.next();
            cb.setProperties(content);
        } catch (IOException e) {
            content = e.getMessage();
        }
        cb.setName(name);
    }

    if (properties != null) {
        cb.setProperties(properties);
    }

    if (basepath != null) {
        String prop = cb.getProperties();
        prop = prop.replaceFirst("[#]?(\\s*?)exp.basepath = (.*?)\n", "# exp.basepath = " + basepath + "\n");
        cb.setProperties(prop);
    }

    coralBeanRepository.save(cb);

    model.put("coral", cb);

    return "edit";
}

From source file:com.flowlogix.ui.MinimizedHandler.java

private String toMinimized(String resourceName) {
    if (!Faces.isDevelopment() && !resourceName.matches(".*\\.min\\.(js|css)$")) {
        if (resourceName.matches(".*\\.(css|js)$")) {
            return resourceName.replaceFirst("(.*)(\\.css|\\.js)$", "$1.min$2");
        }/*from w w  w. j av a 2 s. c  o  m*/
    }
    return resourceName;
}

From source file:fr.inria.corese.rdftograph.driver.OrientDbDriver.java

@Override
public Graph createDatabase(String databasePath) throws IOException {
    String path = databasePath.replaceFirst("plocal:", "");
    super.createDatabase(path);
    graph = new OrientGraphFactory(databasePath);
    BaseConfiguration nodeConfig = new BaseConfiguration();
    nodeConfig.setProperty("type", "NOTUNIQUE");
    nodeConfig.setProperty("keytype", OType.STRING);
    graph.getTx().createVertexIndex(VERTEX_VALUE, RDF_VERTEX_LABEL, nodeConfig);
    nodeConfig = new BaseConfiguration();
    nodeConfig.setProperty("type", "NOTUNIQUE");
    nodeConfig.setProperty("keytype", OType.STRING);
    graph.getTx().createVertexIndex(KIND, RDF_VERTEX_LABEL, nodeConfig);
    nodeConfig = new BaseConfiguration();
    nodeConfig.setProperty("type", "NOTUNIQUE");
    nodeConfig.setProperty("keytype", OType.STRING);
    graph.getTx().createEdgeIndex(EDGE_P, RDF_EDGE_LABEL, nodeConfig);
    g = graph.getTx();/*w ww. j ava  2s  . c o  m*/
    return g;
}