Question

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()?

Was it helpful?

Solution

{([^}]*)}{([^}]*)}([^\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

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top