我解析數據結構如下:正則表達式扔了sre_constants錯誤
var teamFixtures = new WS.Panel(fixturesConfig);
teamFixtures.load([300, [[883762,1,'23-08-2014','17:00',300,'Atalanta',0,777,'Pisa',1,'2 : 0','1 : 0',1,0,'FT','2014/2015','Coppa Italia','1',60,108,5433,11361,'ICI','it','it',0,0,0]
,[883062,1,'16-08-2014','17:00',300,'Atalanta',0,267,'Chievo',0,'3 : 0','1 : 0',1,0,'FT','2014','Club Friendlies','1',57,247,4117,8489,'ICF','it','it',1,0,0]
,[875534,1,'09-08-2014','17:00',300,'Atalanta',0,1501,'Spezia',0,'2 : 0','1 : 0',1,0,'FT','2014','Club Friendlies','1',57,247,4117,8489,'ICF','it','it',1,0,0]
,[875542,1,'06-08-2014','17:00',300,'Atalanta',0,8183,'Feralpisalò',0,'1 : 0','0 : 0',1,0,'FT','2014','Club Friendlies','1',57,247,4117,8489,'ICF','it','it',1,0,0]
,[875541,1,'06-08-2014','15:00',300,'Atalanta',0,7587,'Renate',0,'1 : 0','0 : 0',1,0,'FT','2014','Club Friendlies','1',57,247,4117,8489,'ICF','it','it',1,0,0]
,[848157,1,'02-08-2014','19:30',300,'Atalanta',0,302,'Nantes',0,'*0 : 0','0 : 0',0,0,'PEN','2014','Club Friendlies','1',57,247,4117,8489,'ICF','it','fr',1,0,0]
], [[865781,4,'31-08-2014','17:00',300,'Atalanta',0,76,'Verona',0,'vs',,0,1,,'2014/2015','Serie A','-1',5,108,5441,11369,'ISA','it','it',0,1,0]
,[865791,4,'14-09-2014','14:00',78,'Cagliari',0,300,'Atalanta',0,'vs',,0,0,,'2014/2015','Serie A','-1',5,108,5441,11369,'ISA','it','it',0,1,0]
]]);
我使用下面的正則表達式來定位開幕字符串模式,然後在列表清單中返回的一切:
regex = re.compile('var teamFixtures \= new WS\.Panel\(fixturesConfig\); teamFixtures\.load\([\d+, \[\[.*?\]\]?\)?;', re.S)
這是嘔吐錯誤:
raise error, v # invalid expression
sre_constants.error: unexpected end of regular expression
對我來說,雖然它看起來像我有逃脫了這個表達式中的所有特殊字符,所以我不明白爲什麼我得到這個消息。
任何人都可以看到我在哪裏錯了嗎?
謝謝
忘記了''''附近'\'\ \ \ \ \ \ \ \ [\ d +',但即使你逃脫它,你的正則表達式也是不正確的 – mpcabd 2014-08-31 13:37:10
@mpcabd啊是的,所以我有,謝謝。否則它是錯誤的? – gdogg371 2014-08-31 13:39:36