<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. bzoj2935 [Poi1999]原始生物——欧拉回路

    题目:https://www.lydsy.com/JudgeOnline/problem.php?id=2935 考察欧拉回路性质的题目呢: TJ:https://blog.csdn.net/u014 ...

  2. [JavaEE] JBoss主要版本下载链接一览

    URL: http://teddysun.com/260.html JBoss在2006年被 RedHat 收购.在各种 J2EE 应用服务器中,JBoss 是最受欢迎而且功能最为强大的应用服务器.不 ...

  3. MyEclipse配置https

    1.参照CAS配置(1)SSL证书配置文章配置证书. 2.打开myeclipse的Workspace下的.metadata/.me_tcat7/conf/server.xml 打开文件,添加如下代码 ...

  4. [BZOJ2017][Usaco2009 Nov]硬币游戏(要复习系列)

    又是DP? 好吧,或者说是博弈论,但是我不会啊. 先搞个O(n^3)的记忆化搜索,然后瞎搞好像发现两个状态几乎一样? 竟然过了样例,然后竟然A了... #include<iostream> ...

  5. 【HTTP】如何正常关闭连接

    参考:<HTTP权威指南> 所有HTTP客户端.服务器或者代理都可以任意时刻关闭一条TCP传输连接.但是服务器永远无法确定它关闭“空闲”连接的那一刻,在线路那一头的客户端有没有数据要发送. ...

  6. P1569 [USACO11FEB]属牛的抗议Generic Cow Prote…

    题目描述 Farmer John's N (1 <= N <= 100,000) cows are lined up in a row and numbered 1..N. The cow ...

  7. Java基础13一异常

    1.异常概念 异常是程序在运行期发生的不正常的事件,它会打断指令的正常执行流程. 设计良好的程序应该在异常发生时提供处理这些不正常事件的方法,使程序不会因为异常的发生而阻断或产生不可预见的结果. Ja ...

  8. 出现“ORA-28000:the account is locked”的解决办法

    在Oracle 11g版本中,出于安全的考虑,所有Oracle的默认用户,包括SCOTT用户都被锁定.输入用户名和口令之后,会出现错误“ORA-28000:the account is locked” ...

  9. 远程连接Oracle设置

    1:打开net manager:开始->程序->oracle->配置和移植工具->Net Manager 2:添加服务器名->名子自定义,一般根据项目自定义,自己知道就行 ...

  10. py2exe打包遇到的问题

    py2exe打包python成.exe文件 打包过程和结果 1.创建setup脚本打包文件,其中设置打包的属性和方法.注意:尽量将被打包文件和此打包脚本放在同目录下(因为在尝试非同目录下时,出现了非可 ...