<pre name="code" class="java"><span style="font-family: Arial, Helvetica, sans-serif;"></pre><p>1. reverse</p><p><pre name="code" class="java">   /**</span>

     * @Description: reverse a string.
* @param str the String to reverse, may be null
* @return reversedStr the reversed String, null if null String input
*/
public static String reverse(String str) {
if (isEmpty(str)) {
return str;
} return new StringBuilder(str).reverse().toString();
}

2 . remove

    /**
* @Description: Removes all occurrences of a substring from within the source string.
* @param str the source String to search
* @param remove the String to search for and remove
* @return the substring with the string removed if found, null if null String input
*/
public static String remove(String str, String remove) {
if (isEmpty(str) || isEmpty(remove)) {
return str;
} return str.replace(remove, "");
}

3. startsWithIgnoreCase

    /**
*
* @Title: startsWithIgnoreCase
* @Description: check if a string starts with a specified prefix.
* @param str input value
* @param prefix prefix value
* @return true if the string starts with the prefix, case insensitive, or both null, blank
*/
public static boolean startsWithIgnoreCase(String str, String prefix) {
if (str == null || prefix == null) {
return (str == null && prefix == null);
} if (prefix.length() > str.length()) {
return false;
} return str.toUpperCase().startsWith(prefix.toUpperCase());
}

4. isAllAlphas

   /**
* whether value does not contain number(s).
*
* @Title: isAllAlphas
* @param value the source to be handled
* @return boolean
*/
public static boolean isAllAlphas(String value) {
// if input parameter is null, just return
if (value == null) {
return false;
} for (int i = 0; i < value.length(); i++) {
if (!(Character.isLetter(value.charAt(i)))) {
return false;
}
} return true;
}

5.  isNumeric

  /**
* check if the CharSequence contains only unicode digits.
*
* @Title: isNumber
* @param str input str
* @return true or false
*/
public static boolean isNumeric(String str) {
// if input parameter is null, just return false
if (isEmpty(str)) {
return false;
} for (int i = 0; i < str.length(); i++) {
// if there is a alpha, return false
if (!Character.isDigit(str.charAt(i))) {
return false;
}
} return true;
}

String 经常用法最优算法实现总结 (一)的更多相关文章

  1. String 经常用法最优算法实现总结 (二)

    1. String getOrderedString(boolean isDuplicated, String - str) 说明: Orders all characters in the inpu ...

  2. C#中string.format用法详解

    C#中string.format用法详解 本文实例总结了C#中string.format用法.分享给大家供大家参考.具体分析如下: String.Format 方法的几种定义: String.Form ...

  3. String.format()用法

    package junit.test;   import java.util.Date; import java.util.Locale;   import org.junit.Test;   pub ...

  4. java中String的用法

    String的用法很活跃,也用到的很多.可以根据自己的需要查询API.这里只有concat和substring,indexof的用法 class TestString { public static ...

  5. C#中string.Format 用法详解

    这篇文章主要介绍了C#中string.format用法,以实例形式较为详细的讲述了string.format格式化的各种用法,非常具有实用价值,需要的朋友可以参考下 本文实例总结了C#中string. ...

  6. Oracle中dbms_random.string 的用法

    转载:https://blog.csdn.net/simonchi/article/details/8657787 DBMS_RANDOM.STRING(var1,var2) 这个函数有两个参数 va ...

  7. 关于java中String的用法

    在java 中String存在许多的基本函数,接下来了解一下这些函数的基本用法 String.equals用法(这个用法比较难) String类中的equals()方法: public boolean ...

  8. java成神之——java中string的用法

    java中String的用法 String基本用法 String分割 String拼接 String截取 String换行符和format格式化 String反转字符串和去除空白字符 String获取 ...

  9. string.join用法

    C# String.Join用法 String.Join(String, String[]) 在指定 String 数组的每个元素之间串联指定的分隔符 String,从而产生单个串联的字符串 例如: ...

随机推荐

  1. bzoj 1034 [ ZJOI 2008 ] 泡泡堂BNB —— 贪心

    题目:https://www.lydsy.com/JudgeOnline/problem.php?id=1034 一开始想了个很麻烦的贪心做法,对于每个 a[i],找第一个大于它的 b 匹配…… 然后 ...

  2. 利用 Puppet 实现自动化管理配置 Linux 计算机集群

    随着虚拟化和云计算技术的兴起,计算机集群的自动化管理和配置成为了数据中心运维管理的热点.对于 IaaS.Paas.Saas 来说,随着业务需求的提升,后台计算机集群的数量也会线性增加.对于数据中心的运 ...

  3. 一个能让cin和scanf 一样快的方法:

    cin慢是有原因的,其实默认的时候,cin与stdin总是保持同步的,也就是说这两种方法可以混用,而不必担心文件指针混乱,同时cout和stdout也一样,两者混用不会输出顺序错乱.正因为这个兼容性的 ...

  4. python 线程池和锁

    一.死锁现象与递归锁 锁:Lock线程安全,多线程操作时,内部会让所有线程排队处理.如:list/dict/Queue        线程不安全 + 人 => 排队处理. import thre ...

  5. resultType和resultMap区别,,,1-1一个订单只能对应一个用户,1对多,一个用户对应多个订单

    -----------------1-多

  6. Tour UVA - 1347

    John Doe, a skilled pilot, enjoys traveling. While on vacation, he rents a small plane and starts vi ...

  7. angular js 球星

    <!DOCTYPE html>   <html lang="en">   <head>   <meta charset="UTF ...

  8. [WIFI插座][阅读记录][SoC][RT5350] 00.目录 RALINK AP SDK 4.1.0.0 USER’s MANUAL

    来源是CSDN,百度网盘下载地址 http://pan.baidu.com/share/link?shareid=3504767505&uk=3426044377   授权声明,略过 免责声明 ...

  9. for 循环练习题

    X3 * 6528 = 3X * 8256X为一个数字 填入一个数字 使等式成立 for (var x=1;x<=9&&x>0;x++) { if ((x*10+3)*65 ...

  10. JSP_内置对象_session

    session表示客户端与服务器的一次会话. Web中的session指的是用户在浏览某个网站时,从进入网站到浏览器关闭所经过的这段时间,也就是用户浏览这个网站所花费的时间. 从上述定义中可以看到,s ...