62,621
社区成员
发帖
与我相关
我的任务
分享import java.util.regex.*;
public class MyRegex
{
public static final String ACharSet = "[a-zA-Z0-9]";
public static void main(String[] args)
{
// 这里有多个空格
String s = "0 10 A 市场编号 O 不足长度后补空格, 下同";
// 把2个以上的空格转化成1个空格
s = s.replaceAll(" {2,}", " ");
// 获取属性值,先用空格隔开放进数组里面取出第三个元素值
String sProperty = s.split(" ")[2];
Matcher m = Pattern.compile(ACharSet).matcher(sProperty);
if (m.find())
{
System.out.println("YES");
} else
{
System.out.println("NO");
}
}
}