diff options
| author | David Vazgenovich Shakaryan <dvshakaryan@gmail.com> | 2026-02-05 20:50:31 -0800 |
|---|---|---|
| committer | David Vazgenovich Shakaryan <dvshakaryan@gmail.com> | 2026-02-05 21:15:42 -0800 |
| commit | ef41e8c9a54119628aa8cffb193e42782e69563f (patch) | |
| tree | 1e3492386a7e038850962003157eb42d3becacbb /util.lua | |
| parent | f3ebbfd63352865d07441d1165b4816be3d78b6d (diff) | |
| download | mpv-iptv-menu-ef41e8c9a54119628aa8cffb193e42782e69563f.tar.gz mpv-iptv-menu-ef41e8c9a54119628aa8cffb193e42782e69563f.tar.xz | |
support searching currently playing programmes
Diffstat (limited to 'util.lua')
| -rw-r--r-- | util.lua | 23 |
1 files changed, 23 insertions, 0 deletions
@@ -155,6 +155,29 @@ function util.unflatten_table(src, dst) return dst end +function util.find_matches(str, substr, case_sensitive) + if not str then + return + end + + if not case_sensitive then + str = str:lower() + end + + local matches + local i, j = 0, 0 + while true do + i, j = str:find(substr, j + 1, true) + -- j < i avoids infinite loop on empty substr + if not i or j < i then + break + end + matches = matches or {} + matches[#matches+1] = {start = i, stop = j} + end + return matches or i and {} +end + function util.str_seek_prev_char(str, pos) return util.utf8_seek(str, pos, -1) end |
