1,
Pattern p = Pattern.compile("<.*?>(.*)</.*?>", Pattern.CASE_INSENSITIVE | Pattern.DOTALL);
Matcher matcher = p.matcher(str);
boolean r = matcher.matches();
2,
Pattern pattern = Pattern.compile("Input(.*?)(?=Input|$)");
Matcher matcher = pattern.matcher(s);
while (matcher.find()) {
System.out.println(matcher.group(1));
}
3, test whether the number is from China Mobile
import java.util.regex.Matcher;
import java.util.regex.Pattern;
/**
* @param phoneNumber
* @Description: 這個手機號是否是移動手機號碼
* @Author: tangchuanji
* @Title: isChinaMobileNumber
* @Param: [phoneNumber]
* @Return: boolean
* @Throws:
* @Date: 11:12
*/
@Override
public boolean isChinaMobileNumber(final String phoneNumber) {
final Pattern pattern = Pattern.compile("^1(3[4-9]|5[012789]|8[78])\\d{8}$");
final Matcher matcher = pattern.matcher(phoneNumber);
return matcher.matches();
}