`
lorry1113
  • 浏览: 256177 次
  • 性别: Icon_minigender_1
  • 来自: 北京
社区版块
存档分类
最新评论

正则表达式学习

    博客分类:
  • java
阅读更多
//正则表达式去掉中文
public static void regexDelChinese(){
		
		String str = "a67$bcdefg中文dcba111"; 
		Pattern p=Pattern.compile("[\\u4e00-\\u9fa5]");  
		StringBuffer bf = new StringBuffer();
		for(int i=0; i<str.length(); i++){
			String s = str.substring(i,i+1);
			Matcher m = p.matcher(s); 
			if(m.find()){ 
				System.out.println( "----"+s); 
			}else{ 
				System.out.println( "- "+s); 
				bf.append(s);
			} 
		}
		System.out.println( "-------------"+bf.toString());
	}


//文件移动
public static boolean move(String srcFile, String destPath){ 
		File file = new File(srcFile); 
		File dir = new File(destPath); 

		boolean success = file.renameTo(new File(dir, file.getName()));//移动
		file.delete();//删除
		return success;
	}
分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics