我有html字符串:
<SCRIPT LANGUAGE="JavaScript">
prod155920017Matrix = new Array();
prod155920017Matrix[0] = new Array();
prod155920017Matrix[1] = new Array();
prod155920017Matrix[2] = new Array();
prod155920017Matrix[3] = new Array();
prod155920017Matrix[4] = new Array();
prod155920017Matrix[5] = new Array();
prod155920017Matrix[6] = new Array();
prod155920017Matrix[7] = new Array();
prod155920017Matrix[8] = new Array();
prod155920017Matrix[9] = new Array();
prod155920017Matrix[0][0] = new product('0','prod155920017','sku143650081','36.0B/6.0B','BLACK','Joni Snake-Print Thong Sandal',false,0,'',8,'3','/category/images/prod_stock1.gif',new Array(),'','false',9999,'null');
prod155920017Matrix[0][0].vendorRestrictedDates[0] = '20130903';
prod155920017Matrix[0][0].vendorRestrictedDates[1] = '20131129';
prod155920017Matrix[0][0].vendorRestrictedDates[2] = '20130902';
prod155920017Matrix[0][0].vendorRestrictedDates[3] = '20130101';
prod155920017Matrix[0][0].vendorRestrictedDates[4] = '20121225';
prod155920017Matrix[0][0].vendorRestrictedDates[5] = '20130528';
prod155920017Matrix[0][0].vendorRestrictedDates[6] = '20140102';
prod155920017Matrix[0][0].vendorRestrictedDates[7] = '20140101';
prod155920017Matrix[0][0].vendorRestrictedDates[8] = '20131128';
prod155920017Matrix[0][0].vendorRestrictedDates[9] = '20131226';
prod155920017Matrix[0][0].vendorRestrictedDates[10] = '20121226';
prod155920017Matrix[0][0].vendorRestrictedDates[11] = '20130527';
prod155920017Matrix[0][0].vendorRestrictedDates[12] = '20130705';
prod155920017Matrix[0][0].vendorRestrictedDates[13] = '20131225';
prod155920017Matrix[0][0].vendorRestrictedDates[14] = '20130102';
prod155920017Matrix[0][0].vendorRestrictedDates[15] = '20130704';
prod155920017Matrix[0][0].storeFulfillStatus = 'false';
prod155920017Matrix[1][0] = new product('0','prod155920017','sku143650082','36.5B/6.5B','BLACK','Joni Snake-Print Thong Sandal',false,0,'',10,'3','/category/images/prod_stock1.gif',new Array(),'','false',9999,'null');
</SCRIPT>
我尝试使用此正则表达式:new product(\([^,]*),([^,]*),([^,]*),([^,]*),([^,]*)
从脚本标记获取数据:'36 .0B / 6.0B','BLACK'。但我不能。
请帮我搞定。
非常感谢!
答案 0 :(得分:0)
反斜杠在错误的位置:
new product\(([^,]*),([^,]*),([^,]*),([^,]*),([^,]*)
答案 1 :(得分:0)
\'\d{2}\.\d[A-Z]\/\d\.\d[A-Z]\',\'[\w]+\'
这应该可以获得预期的结果。 因为正则表达式只能进行模式匹配,所以你不能使用正则表达式在结果字符串周围添加像(和)这样的字符,你必须使用python来做。