re: VBA编程心得 风舞者 2008-09-16 11:31
breezedancer@yahoo.cn,谢谢,发我一封
re: 超强的正则表达式(zt) 风舞者 2007-10-10 16:14
package com.datamininfo;
import java.util.ArrayList;
import java.util.List;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
public class MobileNumber {
public static void main(String[] args) {
MobileNumber mn = new MobileNumber();
mn.getNumber(null);
}
/**
* 提取号码
*
* @param s
* @return
*/
@SuppressWarnings("unchecked")
public List getNumber(String s) {
List list = new ArrayList();
if (s == null) {
return list;
}
String pattern = "(\\D|)(086|86|0|)(13|15)(\\d{9})";
Pattern pattern1 = Pattern.compile(pattern);
Matcher matcher = pattern1.matcher(s);
while (matcher.find()) {
list.add(matcher.group(3) + matcher.group(4));
}
/*
* System.out.println("length="+list.size()); for(int j=0;j<list.size();j++){
* System.out.println(list.get(j)); }
*/
return list;
}
/**
* 判断是否是全数字
*
* @param mobile
* @return
*/
public boolean isNumber(String mobile) {
boolean b = true;
int i = 0;
while (i < mobile.length() && Character.isDigit(mobile.charAt(i))) {
i++;
}
if (i != mobile.length())
b = false;
System.out.println(i);
return b;
}
/**
* 取得名字,如果是英文,不动,如果是中英文,取中文
*
* @param name
* @return
*/
public String modifyName(String name) {
if (name == null)
return "";
String pattern = "^([^\\w]+)(\\w+| |)";
Pattern pattern1 = Pattern.compile(pattern, Pattern.CASE_INSENSITIVE);
Matcher matcher = pattern1.matcher(name);
while (matcher.find()) {
// System.out.println(matcher.groupCount());
name = matcher.group(1);
// System.out.println(name=matcher.group(1));
// System.out.println(matcher.group(2));
}
// System.out.println(name);
return name;
}
/**
* 删除字母数字下划线空白符号\r\n etc.
*
* @param job
* @return
*/
public String delWord(String job) {
if (job == null)
return "";
String pattern = "\\w|\\s";
Pattern pattern1 = Pattern.compile(pattern, Pattern.CASE_INSENSITIVE);
Matcher matcher = pattern1.matcher(job);
StringBuffer s = new StringBuffer();
while (matcher.find()) {
matcher.appendReplacement(s, "");
}
matcher.appendTail(s);
// System.out.println(s);
return s.toString();
}
}
re: 系统分析师最新资料 风舞者 2007-08-27 12:57
breezedanc@gmail.com
谢谢~~~