문제

How to write a pattern for parsing .sub format?

Subtitles are in format: {start-frame}{stop-frame}Text (detail: http://en.wikipedia.org/wiki/MicroDVD)

Example:

{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.

How to get the following parameters (start,stop frame and text) using PHP preg_match()?

도움이 되었습니까?

해결책

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

  • Group 1: match anything until }
  • Group 2: Match anything until }
  • Group 3: Match anything until a new line.

You can see it here

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top