Libraryless. Click here for Pure Java version (5437L/30K).
1 | static L<SRTEntry> parseIncompleteSRT(S text) { |
2 | LS entries = splitAtEmptyLines(text); |
3 | ret mapWithIndex(entries, (idx, input) -> { |
4 | LS lines = trimAll(lines(input)); |
5 | new SRTEntry e; |
6 | if (isInteger(first(lines))) |
7 | lines = dropFirst(lines); |
8 | LS time = regexpFirstGroups("^(\\d+):(\\d+)", first(lines)); |
9 | if (time != null) { |
10 | e.start = parseInt(first(time))*60+parseInt(second(time)); |
11 | e.end = e.start+2; |
12 | lines = dropFirst(lines); |
13 | } |
14 | e.index = idx+1; |
15 | e.text = lines(lines); |
16 | ret e; |
17 | }); |
18 | } |
download show line numbers debug dex old transpilations
Travelled to 3 computer(s): bhatertpkbcr, ekrmjmnbrukm, mqqgnosmbjvj
No comments. add comment
Snippet ID: | #1033617 |
Snippet name: | parseIncompleteSRT |
Eternal ID of this version: | #1033617/2 |
Text MD5: | a8dd9111ba7d0dd3323e4ff948e69d6f |
Transpilation MD5: | 9c62e8300e4bbd7f6b63d7ecb0688a6c |
Author: | stefan |
Category: | javax |
Type: | JavaX fragment (include) |
Public (visible to everyone): | Yes |
Archived (hidden from active list): | No |
Created/modified: | 2021-11-26 00:37:19 |
Source code size: | 557 bytes / 18 lines |
Pitched / IR pitched: | No / No |
Views / Downloads: | 171 / 239 |
Version history: | 1 change(s) |
Referenced in: | [show references] |