1.设定正则规则
String regex = "\\?ut=([\\S]*?)&";\\字符串的开头是?ut=,中间的内容是任意字符,结尾是&
2.创建正则表达式对象
(content);
Pattern pattern = (regex);
3.用对象去匹配内容content)
Matcher matcher = (content);
4.执行匹配操作
();
5.获取匹配的字符串内容
String group = ();
实例:
String a= "10/12)";
Pattern pattern = ("^\\d{1,2}\\W\\d{1,2}");
Matcher matcher = (a);
();
String group = ();
("截取到内容是:" + group);