废话不多说,直接开始干活!
.点 匹配任何单个字符 。* 匹配0或多个正好在它之前的那个字符。例如正则表达式。*意味着能够匹配任意数量的任何字符。? 匹配0或1个正好在它之前的那个字符。注意:这个元字符不是所有的软件都支持的。
有点眼花
.*? .点 匹配任何单个字符。 * 匹配0或多个正好在它之前的那个字符。 ? 匹配0或1个正好在它之前的那个字符。直接上代码
import console; import string; var str = //jQuery1982868({"CommentsCount":[{"SkuId":4217490,"ProductId":4217490,"ShowCount":18903,"ShowCountStr":"1.8万+","CommentCountStr":"62万+","CommentCount":621876,"AverageScore":5,"DefaultGoodCountStr":"48万+","DefaultGoodCount":483003,"GoodCountStr":"33万+","GoodCount":334709,"AfterCount":1533,"OneYear":0,"AfterCountStr":"1500+","VideoCount":689,"VideoCountStr":"600+","GoodRate":0.99,"GoodRateShow":99,"GoodRateStyle":148,"GeneralCountStr":"1300+","GeneralCount":1334,"GeneralRate":0.008,"GeneralRateShow":1,"GeneralRateStyle":2,"PoorCountStr":"800+","PoorCount":820,"SensitiveBook":0,"PoorRate":0.002,"PoorRateShow":0,"PoorRateStyle":0}]}); paten=".*CommentCount.*?(\d+)," var m,m2=string.match(str,paten) console.log(m) execute("pause")耗时耗力,找了半天终于找到方法,感觉还需优化!
如图