Android examples for java.util.regex:Digit Pattern
get Verify Code From Sms which is six digits by regular expression
import android.text.TextUtils; import java.util.regex.Matcher; import java.util.regex.Pattern; public class Main{ public static String getVerifyCodeFromSms(String smsBody) { Pattern pattern = Pattern.compile("\\d{6}"); Matcher matcher = pattern.matcher(smsBody); if (matcher.find()) { return matcher.group(); }//from ww w.ja v a2 s. c o m return null; } }