Skip to content

Instantly share code, notes, and snippets.

@zxlooong
Last active December 15, 2015 05:49
Show Gist options
  • Save zxlooong/5211885 to your computer and use it in GitHub Desktop.
Save zxlooong/5211885 to your computer and use it in GitHub Desktop.
AuthCodePhone.java
import java.util.regex.Pattern;
import java.util.regex.Matcher;
public class AuthCodePhone {
public static String parseMsg(String msg) {
String sensitive = "";
Pattern p = Pattern.compile(EXP);
Matcher m = p.matcher(msg);
boolean bfind = m.find();
if (bfind) {
sensitive = m.group(0);
}
return sensitive;
}
private static final String EXP = "\\d{6}|\\d{4}";
public static void main(String[] args) {
// TODO Auto-generated method stub
String msg1 = "1234.";
String findout = AuthCodePhone.parseMsg(msg1);
System.out.println(findout);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment