辅助字符串处理类:org.apache.commons.lang3.StringUtils
2024-10-18 00:47:35
api 地址:http://commons.apache.org/proper/commons-lang/apidocs/index.html?index-all.html
StringUtils 常用方法:
方法 | 作用 |
---|---|
isBlank | 判断某字符串是否为空、长度为0、由空白符(whitespace) 构成。isBlank(" ")为true。多数情况用 isBlank |
isEmpty | 判断某字符串是否为空,为空的标准是 strnull 或 str.length()0。isEmpty(" ")为false |
trim | 去掉字符串两端的控制符(control characters, char <= 32)。如果为null或"",则返回null |
strip | 去掉字符串两端的空白符(whitespace)。如果输入为null则返回null |
- StringUtils 说明:
Operations on String that are null safe.
IsEmpty/IsBlank - checks if a String contains text
Trim/Strip - removes leading and trailing whitespace
Equals/Compare - compares two strings null-safe
startsWith - check if a String starts with a prefix null-safe
endsWith - check if a String ends with a suffix null-safe
IndexOf/LastIndexOf/Contains - null-safe index-of checks
IndexOfAny/LastIndexOfAny/IndexOfAnyBut/LastIndexOfAnyBut - index-of any of a set of Strings
ContainsOnly/ContainsNone/ContainsAny - does String contains only/none/any of these characters
Substring/Left/Right/Mid - null-safe substring extractions
SubstringBefore/SubstringAfter/SubstringBetween - substring extraction relative to other strings
Split/Join - splits a String into an array of substrings and vice versa
Remove/Delete - removes part of a String
Replace/Overlay - Searches a String and replaces one String with another
Chomp/Chop - removes the last part of a String
AppendIfMissing - appends a suffix to the end of the String if not present
PrependIfMissing - prepends a prefix to the start of the String if not present
LeftPad/RightPad/Center/Repeat - pads a String
UpperCase/LowerCase/SwapCase/Capitalize/Uncapitalize - changes the case of a String
CountMatches - counts the number of occurrences of one String in another
IsAlpha/IsNumeric/IsWhitespace/IsAsciiPrintable - checks the characters in a String
DefaultString - protects against a null input String
Rotate - rotate (circular shift) a String
Reverse/ReverseDelimited - reverses a String
Abbreviate - abbreviates a string using ellipsis or another given String
Difference - compares Strings and reports on their differences
LevenshteinDistance - the number of changes needed to change one String into another
The StringUtils class defines certain words related to String handling.
null - null
empty - a zero-length string ("")
space - the space character (' ', char 32)
whitespace - the characters defined by Character.isWhitespace(char)
trim - the characters <= 32 as in String.trim()
最新文章
- Ionic页面加载前 ionic页面加载完成 ionic页面销毁执行的事件
- 初学python之安装Jupyter notebook
- where和having子句的区别
- 外部dtd
- XML通過XSD產生CLASS
- wait、waitpid 僵尸进程 孤儿进程
- hdu 4315 Climbing the Hill 博弈论
- python学习[二]
- android拦截短信并屏蔽系统的Notification
- 解决浏览器兼容问题的css hack
- webstorm常用快捷键及(idea,phpstorm,android studio通用)使用技巧
- Chapter 14_5 _ENV和load
- Google 怎么搜索
- HDU 3569 Imaginary Date 简单期望
- 【C#附源码】数据库文档生成工具支持(Excel+Htm)
- C#编程语言之委托与事件(二)—— C#事件
- shell脚本学习-执行
- PD915温度太高,通过设置BIOS降底CPU的核心电压来降温。
- PHP - CentOS下开发运行环境搭建(Apache+PHP+MySQL+FTP)
- SQL数据查询之——单表查询