指定字符串后取数字文本的正则表达式?内容如下:
{"retcode":0,"result":{"uinlist":[{"uiuin":"","face":486,"sex":1,"nick":"风/tp","age":...
{"retcode":0,"result":{"uinlist":[{"uiuin":"","face":486,"sex":1,"nick":"风/tp","age":33,"province":"湖北","uin":231423409,"stat":10,"country":"中国","city":"0"},{"uiuin":"","face":558,"sex":2,"nick":"兰","age":29,"province":"广东","uin":1770946938,"stat":10,"country":"中国","city":"江门
取每一个"uin":后面的如:1159950678 这样的数字文本 展开
取每一个"uin":后面的如:1159950678 这样的数字文本 展开
2个回答
展开全部
获取每一个"uin":后面的数字的程序如下:
import java.util.regex.Matcher;
import java.util.regex.Pattern;
public class RR {
public static void main(String[] args) {
String s="{\"retcode\":0,\"result\":{\"uinlist\":[{\"uiuin\":\"\",\"face\":486,\"sex\":1,\"nick\":\"风/tp\",\"age\":33,\"province\":\"湖北\",\"uin\":231423409,\"stat\":10,\"country\":\"中国\",\"city\":\"0\"},{\"uiuin\":\"\",\"face\":558,\"sex\":2,\"nick\":\"兰\",\"age\":29,\"province\":\"广东\",\"uin\":1770946938,\"stat\":10,\"country\":\"中国\",\"city\":\"江门";
String regex="\\\"uin\\\"\\:([0-9]+)";
Pattern p=Pattern.compile(regex);
Matcher m=p.matcher(s);
while(m.find()){
System.out.println(m.group(1));
}
}
}
运行结果:
231423409
1770946938
正则表达式:
\\\"uin\\\"\\:([0-9]+)
import java.util.regex.Matcher;
import java.util.regex.Pattern;
public class RR {
public static void main(String[] args) {
String s="{\"retcode\":0,\"result\":{\"uinlist\":[{\"uiuin\":\"\",\"face\":486,\"sex\":1,\"nick\":\"风/tp\",\"age\":33,\"province\":\"湖北\",\"uin\":231423409,\"stat\":10,\"country\":\"中国\",\"city\":\"0\"},{\"uiuin\":\"\",\"face\":558,\"sex\":2,\"nick\":\"兰\",\"age\":29,\"province\":\"广东\",\"uin\":1770946938,\"stat\":10,\"country\":\"中国\",\"city\":\"江门";
String regex="\\\"uin\\\"\\:([0-9]+)";
Pattern p=Pattern.compile(regex);
Matcher m=p.matcher(s);
while(m.find()){
System.out.println(m.group(1));
}
}
}
运行结果:
231423409
1770946938
正则表达式:
\\\"uin\\\"\\:([0-9]+)
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询