Java tutorial
//package com.java2s; 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(); } return null; } }