如题所述
import java.util.regex.Matcher;
import java.util.regex.Pattern;
public class PatternDemo {
/**
* @param args
*/
public static void main(String[] args) {
String str = ",a b c,a,c";
Pattern pattern = Pattern.compile("a[^,]*c");
Matcher matcher = pattern.matcher(str);
while(matcher.find()){
System.out.println(matcher.group());
}
}
}
import java.util.regex.Pattern;
public class PatternDemo {
/**
* @param args
*/
public static void main(String[] args) {
String str = ",a b c,a,c";
Pattern pattern = Pattern.compile("a[^,]*c");
Matcher matcher = pattern.matcher(str);
while(matcher.find()){
System.out.println(matcher.group());
}
}
}
温馨提示:答案为网友推荐,仅供参考