java正则匹配字符串例子

import java.util.regex.Matcher;
import java.util.regex.Pattern;

public class sss {
public static void main(String[] args) {
String s="\"F039\":\"96\",\"F117\"";
String regex = "F039\":\"(.+?),\"F117";
Pattern pattern = Pattern.compile(regex);
Matcher matcher = pattern.matcher(s);
if (matcher.find()) {
System.out.println(matcher.group());
System.out.println(matcher.group().substring(7, matcher.group().length()-7));

}
}
}

上一篇:C++基础-正则表达式 regex_match(匹配) regex_search(查找) regex_replace(替换)


下一篇:C# Regex正则验证规则