List of usage examples for java.lang String replaceFirst
public String replaceFirst(String regex, String replacement)
From source file:com.mgmtp.jfunk.core.JFunk.java
private static String normalizeScriptParameterValue(final String value) { if (value.startsWith("$_{") && value.endsWith("}")) { return value.replaceFirst("\\$_\\{", "\\${"); }/*from w w w . j a v a 2s. c om*/ return value; }
From source file:control.Functions.java
public static boolean isMeasurementOfBarcode(String code, String type) { String prefix = type.split("_")[1]; code = code.replaceFirst(prefix, ""); return isQbicBarcode(code); }
From source file:info.guardianproject.netcipher.NetCipher.java
/** * Get a {@link HttpsURLConnection} from a URL {@link String} using the best * TLS configuration available on the device. * * @param urlString//from w ww .j ava 2s.c o m * @return the URL in an instance of {@link HttpsURLConnection} * @throws IOException * @throws IllegalArgumentException if the proxy or TLS setup is incorrect, * or if an HTTP URL is given that does not support HTTPS */ public static HttpsURLConnection getHttpsURLConnection(String urlString) throws IOException { URL url = new URL(urlString.replaceFirst("^[Hh][Tt][Tt][Pp]:", "https:")); return getHttpsURLConnection(url, false); }
From source file:eu.planets_project.tb.gui.backing.data.DigitalObjectInspector.java
/** * There are some characters that are allowed in URLs and should not be escaped as %xx * e.g. blanks. These are not allowed in URIs. * This method uses the URI constructor to fix those escapings. * @param uri/*from w w w .j a va 2 s. c o m*/ * @return */ public static URI uriEncoder(String uri) { if (uri == null || uri.length() == 0) return null; try { URI nuri = new URI("planets", uri.replaceFirst("planets:", ""), null); return nuri; } catch (URISyntaxException e) { e.printStackTrace(); return null; } }
From source file:edu.sdsc.scigraph.neo4j.GraphUtil.java
/*** * Returns the "fragment" of an IRI//from w w w .j a v a 2 s .c o m * * <p>Due to historical ID spaces the fragment is * the true RFC3987 fragment (foo in http://example.org#foo) if the {@code uri} has one. * If a true fragment is not present then the fragment is the final path element * (foo in http://example.org/foo) * * @param iri uri with a fragment * @return the "fragment" of the IRI */ public static String getFragment(String iri) { if (validator.isValid(checkNotNull(iri))) { if (iri.contains("#")) { return iri.substring(iri.lastIndexOf('#') + 1); } else { return iri.replaceFirst(".*/(.*)", "$1"); } } else if (iri.startsWith("_:")) { return iri; } else if (iri.startsWith("mailto:")) { return iri.substring("mailto:".length()); } else { logger.warning("Failed to find a fragment for IRI: " + iri); throw new IllegalArgumentException("Failed to find a fragment for IRI: " + iri); } }
From source file:com.zfer.kit.StrKit.java
/** * ?????./*from w ww.ja v a 2 s . c o m*/ * * @param str input param * @param fix input param * @param array input param * @return replace str width array[i] and append by fix */ public static String replace(String str, String fix, String[] array) { String rs = str; for (String anArray : array) { rs = rs.replaceFirst(fix, anArray); } return rs; }
From source file:com.android.i18n.addressinput.FormatInterpreter.java
private static String removeRedundantSpacesAndLeadingPunctuation(String str) { // Remove leading commas and other punctuation that might have been added by the formatter // in the case of missing data. str = str.replaceFirst("^[-,\\s]+", ""); str = str.trim();/*w ww . j a va 2s . c o m*/ str = str.replaceAll(" +", " "); return str; }
From source file:gridool.db.partitioning.phihash.monetdb.MonetDBCsvLoadOperation.java
private static String getCopyIntoQuery(@Nonnull final String query, final long numRecords, @Nonnegative final long offset) { return query.replaceFirst("COPY ", "COPY " + numRecords + " OFFSET " + offset + " RECORDS "); }
From source file:uk.ac.sanger.cgp.wwdocker.actions.Utils.java
public static File expandUserFilePath(BaseConfiguration config, String parameter, boolean checkExists) { String localTmp = config.getString(parameter); if (localTmp.startsWith("~")) { logger.trace("Attempting to expand path: " + localTmp); if (localTmp.startsWith("~/")) { localTmp = localTmp.replaceFirst("^~", System.getProperty("user.home")); } else {//from w w w . j a va 2s.c o m throw new RuntimeException( "Config value for '" + parameter + "' must be a full path or begin '~/'"); } logger.trace("Expanded path: " + localTmp); } File expanded = new File(localTmp); if (!expanded.exists()) { throw new RuntimeException("File or path indicated by '" + parameter + "=" + config.getString(parameter) + "' does not exist once expanded to '" + localTmp + "'"); } return expanded; }
From source file:org.duracloud.duradmin.util.SpaceUtil.java
public static String formatAclDisplayName(String key) { String prefix = "group-"; if (key.startsWith(prefix)) { return key.replaceFirst(prefix, ""); }// w ww . jav a2s . com return key; }