I am trying to extract all the mappings from an EBML definition, something like this:
| + A track
| + Track number: 3
| + Track UID: 724222477
| + Track type: subtitles
...
| + Language: eng
...
| + A track
| + Track number: 4
| + Track UID: 745646561
| + Track type: subtitles
...
| + Language: jpn
...
I need all occurrences of "Language: ???" when "Track Type: Subtitles" precedes. I tried several variations of this:
Track type: subtitles.*Language: (\w\w\w)
I use a multi-line modifier in Ruby to match newlines (for example, the 's' modifier in other languages).
This works to get the last event , which in the example above will be "jpn", for example:
string.scan(/Track type: subtitles.*Language: (\w\w\w)/m)
=> [["jpn"]]
As a result, I would like to:
=> [["eng"], ["jpn"]]
What would be the correct regular expression to accomplish this?
source
share