Libraryless. Click here for Pure Java version (5437L/30K).
static L<SRTEntry> parseIncompleteSRT(S text) { LS entries = splitAtEmptyLines(text); ret mapWithIndex(entries, (idx, input) -> { LS lines = trimAll(lines(input)); new SRTEntry e; if (isInteger(first(lines))) lines = dropFirst(lines); LS time = regexpFirstGroups("^(\\d+):(\\d+)", first(lines)); if (time != null) { e.start = parseInt(first(time))*60+parseInt(second(time)); e.end = e.start+2; lines = dropFirst(lines); } e.index = idx+1; e.text = lines(lines); ret e; }); }
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: | 359 / 466 |
| Version history: | 1 change(s) |
| Referenced in: | [show references] |