List of usage examples for java.lang String replaceFirst
public String replaceFirst(String regex, String replacement)
From source file:Main.java
public static String filterFirstZero(String str) { if (!str.contains(".")) { return str.replaceFirst("^0*", ""); }/*from w w w. j a v a 2 s . c o m*/ return str; }
From source file:Main.java
public static String getTwitterUserFromUrl(String sourceUrl) { String user = sourceUrl.replaceFirst("#!/", ""); int index = user.indexOf(".com/"); if (index > 0) { index += ".com/".length(); int index2 = user.indexOf("/", index); if (index2 < 0) index2 = user.length();/*from w w w . jav a 2 s. c o m*/ user = user.substring(index, index2); } return user.toLowerCase(); }
From source file:com.shazam.fork.utils.ReadableNames.java
public static String readableTestMethodName(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 String toString(String[] permission) { if (permission == null || permission.length <= 0) { return ""; }/*w ww .j a v a2 s .c om*/ StringBuilder sb = new StringBuilder(); for (String p : permission) { sb.append(p.replaceFirst("android.permission.", "")); sb.append(","); } sb.deleteCharAt(sb.length() - 1); return sb.toString(); }
From source file:Main.java
public static Object getProperty(Object o, String field) { try {/*w ww.ja v a 2 s . co m*/ Field f = o.getClass().getDeclaredField(field); f.setAccessible(true); String name = f.getName(); name = name.replaceFirst(name.substring(0, 1), name.substring(0, 1).toUpperCase(Locale.US)); Method m = o.getClass().getMethod("get" + name); // return f.get(o); return (Object) m.invoke(o); } catch (Exception e) { e.printStackTrace(); } return null; }
From source file:Main.java
/** * Checks whether the filename looks legitimate *//*ww w . j a v a 2 s. co m*/ static boolean isFilenameValid(String filename, File downloadsDataDir) { filename = filename.replaceFirst("/+", "/"); // normalize leading slashes return filename.startsWith(Environment.getDownloadCacheDirectory().toString()) || filename.startsWith(downloadsDataDir.toString()) || filename.startsWith(Environment.getExternalStorageDirectory().toString()); }
From source file:com.semsaas.utils.anyurl.App.java
private static String rewriteEndpoint(String target) { return target.replaceFirst("^http:", "http4:").replaceFirst("^https:", "https4:"); }
From source file:Main.java
private static String getFirstLowerVariables(String variables) { String firstLetter = variables.substring(0, 1); variables = variables.replaceFirst(firstLetter, firstLetter.toLowerCase()); return variables; }
From source file:Main.java
public static String format(String str, String... args) { for (int i = 0; i < args.length; i++) { str = str.replaceFirst("\\{" + i + "\\}", args[i]); }/*from ww w . ja v a 2s . c om*/ return str; }
From source file:Main.java
public static String getHost(String url) { if ((url == null) || (url.equals(""))) return null; url = url.replaceFirst("http://", ""); return url.substring(0, url.indexOf("/")); }