package sample1;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
public class demo1 {
public static void main(String[] args) {
String str = " 你好,空指针,Welcome to 游戏大厅! ";
Pattern pattern = Pattern.compile("[a-zA-Z0-9]");
Matcher matcher = pattern.matcher(str);
if (matcher.find()) {
System.out.println(str.indexOf(matcher.group()));
}
}
} |