Last active
December 15, 2015 05:49
-
-
Save zxlooong/5211885 to your computer and use it in GitHub Desktop.
AuthCodePhone.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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