Regex expressions in Java \\s vs.\\s+
来源:互联网 发布:凯立德端口查看 编辑:程序博客网 时间:2024/04/28 02:02
x = x.replaceAll("\\s", "");x = x.replaceAll("\\s+", "");
Those two replaceAll
calls will always produce the same result, regardless of what x
is. However, it is important to note that the two regular expressions are not the same:
\\s
- matches single whitespace character\\s+
- matches sequence of one or more whitespace characters.
In this case, it makes no difference, since you are replacing everything with an empty string (although it would be better to use \\s+
from an efficiency point of view). If you were replacing with a non-empty string, the two would behave differently.
0 0
- Regex expressions in Java \\s vs.\\s+
- Java‘s regular expressions
- c++98's regex
- Regular Expressions (3) ---- Using Regex in .NET
- Regular Expressions (3) ---- Using Regex in .NET
- Garbage Collectors – Serial vs. Parallel vs. CMS vs. G1 (and what’s new in Java 8)
- JXL'S APPLICATION IN JAVA
- Regular Expressions in Java
- Regular Expressions in C++ with Boost.Regex(1)
- Regular Expressions in C++ with Boost.Regex(2)
- Regular Expressions in C++ with Boost.Regex(3)
- Regular Expressions in C++ with Boost.Regex(4)
- microsoft s+s vs SaaS
- B/S vs C/S
- 【C/S】 VS 【B/S】
- B/S VS C/S
- B/S VS C/S
- C/S VS B/S
- iOS中消息的传递机制
- oracle数据库中,数据表无法执行数据操作语句,提示记录已被锁住
- 为什么不要用 StringBuffer 和 Vector
- 状态机的实现
- java 的运行机制之classload
- Regex expressions in Java \\s vs.\\s+
- glutSwapBuffers函数用法
- 开始
- onNewIntent
- string和stringstream用法总结
- 黑马程序员——java-网络编程
- eclipse基础知识
- Linux下安装Flash插件
- hdu 2089 不要62(数位dp)