2013-08-26 25 views
1

如何編寫解析.sub格式的模式?.sub字幕格式的正則表達式模式

字幕是在格式:{開始幀} {停幀}文字 (細節:http://en.wikipedia.org/wiki/MicroDVD

實施例:

{1446}{1493}Roger, transport.|This is Grissom gate control. 
{1494}{1521}Please download security codes. 
{1522}{1551}Downloading. 
{1552}{1622}Transport, I've got two blips|inside your radar signature. 
{1622}{1653}They're hiding in your shadow. 
{1654}{1686}I don't see anything. 
{1808}{1875}This is gate control.|Battle stations. 

如何獲得以下參數(啓動,停止框架和文本)使用PHP preg_match()?

回答

3

{([^}]*)}{([^}]*)}([^\r\n]*)

  • 組1:匹配任何東西,直到}
  • 組2:匹配任何東西,直到}
  • 組3:匹配任何東西,直到一個新行。

你可以看到它here