正则表达式,字符串分割,以及分割后的字符串数组的长度
2016-03-31 17:46
393 查看
public class TestString { public static void main(String[] args) { String str = "AaaaABBBBcc&^%adfsfdCCOOkk99876 _haHA"; String[] upStr = str.split("[a-z0-9&^% _]"); System.out.println("Printout uppercase"); for (String outUp : upStr){ System.out.print(outUp); } System.out.println("\n" + upStr.length); //the "length" is not real, so, where is it comes from? //How could we get real length? System.out.println("\n Printout lowercase"); String[] lowStr = str.split("[A-Z0-9&^% _]"); for (String outLow : lowStr){ System.out.print(outLow); } System.out.println("\n" + lowStr.length); System.out.println("\n non-English"); String[] nonEng = str.split("[A-Za-z]"); for (String outNonEng : nonEng){ System.out.print(outNonEng); } System.out.println("\n" + nonEng.length); } }
同样的问题我也在Stackoverflow(一个问答形式的编程网站)提问了,等待回答中。
国内也有人讲解过类似问题,长篇大论,但不是干粮。
相关文章推荐
- msql 正则表达式
- 正则表达式
- Mootools 1.2教程 正则表达式
- 分割超大Redis数据库例子
- 批处理FINDSTR正则表达式用法实例分析
- vbs正则表达式代码
- C#文件分割的方法
- C#正则表达式Regex类的常用匹配
- C#中利用正则表达式将人民币金额转换为大写汉字
- C#使用正则表达式实现首字母转大写的方法
- php中看实例学正则表达式
- PHP正则表达式之定界符和原子介绍
- PHP下常用正则表达式整理
- 批处理 正则表达式(findstr) 整理
- 详解C#正则表达式Regex常用匹配
- php把大写命名转换成下划线分割命名
- C#正则表达式的6个简单例子
- JS截取与分割字符串常用技巧总结
- JavaScript类型系统之正则表达式