<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. Python入门 不必自己造轮子

    操作list list切片 字符串的分割 字符串的索引和切片 读文件 f = file('data.txt') data = f.read() print data f.close() 写文件 dat ...

  2. Network Saboteur(dfs)

    http://poj.org/problem?id=2531 不太理解这个代码... #include <stdio.h> #include <string.h> ][],v[ ...

  3. bzoj 2152 聪聪可可(点分治模板)

    2152: 聪聪可可 Time Limit: 3 Sec  Memory Limit: 259 MBSubmit: 3194  Solved: 1647[Submit][Status][Discuss ...

  4. Integer应该用==还是equals

    问题引出:“Integer应该用==还是equals” 讨论这个问题之前我们先放一段代码 public static void main(String[] args) { Integer a1 = 2 ...

  5. 猜拳游戏项目(涉及知识点Scanner、Random、For、数组、Break、Continue等)

    package day03.d3.xunhuankongzhi; import java.util.Scanner; public class CaiQuan { public static void ...

  6. 【java基础】(6)内部类

    内部类不是很好理解,但说白了其实也就是一个类中还包含着另外一个类 如同一个人是由大脑.肢体.器官等身体结果组成,而内部类相当于其中的某个器官之一,例如心脏:它也有自己的属性和行为(血液.跳动) 显然, ...

  7. (转)Vue 爬坑之路(一)—— 使用 vue-cli 搭建项目

    vue-cli 是一个官方发布 vue.js 项目脚手架,使用 vue-cli 可以快速创建 vue 项目,GitHub地址是:https://github.com/vuejs/vue-cli 一. ...

  8. H265

    H265 h265  一.名词 CTU: 编码树单元 CU: 编码单元 PU: 以CU为根,对CU进行划分,一个预测单元PU包含一个亮度预测块PB和两个色度预测块PB. TU: 以CU为根,变换单元T ...

  9. MatLab之Simulink之simple model

    Use Simulink to model a system and then simulate the dynamic behavior of that system. 1 Open in Comm ...

  10. ROS:ubuntu-Ros使用OrbSLAM

    一般无误的官方连接:https://github.com/raulmur/ORB_SLAM ubuntu16.04没有多少改变,还是使用kinetic老代替indigo Related Publica ...