Java tutorial
//package com.java2s; import android.text.TextUtils; import java.util.regex.Matcher; import java.util.regex.Pattern; public class Main { public static String patternLoginVerificationCode(String patternContent) { if (TextUtils.isEmpty(patternContent)) { return null; } Pattern p = Pattern.compile("(?<!\\d)\\d{6}(?!\\d)"); Matcher matcher = p.matcher(patternContent); if (matcher.find()) { return matcher.group(); } return null; } }