6cde949a2c 2024-01-23 1: local 字集码互转库 = require("u8_to_a")
bb2048dbf7 2024-01-23 2: local d_5 = {}
bb2048dbf7 2024-01-23 3: local 简件系库 = require("lfs")
bb2048dbf7 2024-01-23 4: function _G.require_u8(modname)
6cde949a2c 2024-01-23 5: return require(字集码互转库.u8_to_a(modname))
bb2048dbf7 2024-01-23 6: end
bb2048dbf7 2024-01-23 7: do
bb2048dbf7 2024-01-23 8: local k1 = 0
bb2048dbf7 2024-01-23 9: function _G.递增示()
bb2048dbf7 2024-01-23 10: k1 = k1 + 1
bb2048dbf7 2024-01-23 11: print(k1)
bb2048dbf7 2024-01-23 12: end
bb2048dbf7 2024-01-23 13: end
bb2048dbf7 2024-01-23 14: --~ do
bb2048dbf7 2024-01-23 15: --~ local k1 = os.execute
bb2048dbf7 2024-01-23 16: --~ function _G.os.execute(command)
6cde949a2c 2024-01-23 17: --~ return k1(字集码互转库.u2a(command))
bb2048dbf7 2024-01-23 18: --~ end
bb2048dbf7 2024-01-23 19: --~ end
bb2048dbf7 2024-01-23 20: function d_5.读件(o1, o2)
bb2048dbf7 2024-01-23 21: local k1
bb2048dbf7 2024-01-23 22: local k1_3
bb2048dbf7 2024-01-23 23: k1_3 = io.open(o1, o2 or "r")
bb2048dbf7 2024-01-23 24: k1 = k1_3:read("a")
bb2048dbf7 2024-01-23 25: k1_3:flush()
bb2048dbf7 2024-01-23 26: k1_3:close()
bb2048dbf7 2024-01-23 27: return k1
bb2048dbf7 2024-01-23 28: end
bb2048dbf7 2024-01-23 29: function d_5.读件排(o1_9, o1)
bb2048dbf7 2024-01-23 30: local k1_9
bb2048dbf7 2024-01-23 31: k1_9 = {}
bb2048dbf7 2024-01-23 32: for o2 = 1, #o1_9 do
bb2048dbf7 2024-01-23 33: k1_9[#k1_9 + 1] = d_5.读件(o1_9[o2], o1)
bb2048dbf7 2024-01-23 34: end
bb2048dbf7 2024-01-23 35: return k1_9
bb2048dbf7 2024-01-23 36: end
bb2048dbf7 2024-01-23 37: function d_5.写件(o1, o2, o3)
bb2048dbf7 2024-01-23 38: local k1_3
bb2048dbf7 2024-01-23 39: k1_3 = io.open(o1, o3 or "w")
bb2048dbf7 2024-01-23 40: k1_3:write(o2)
bb2048dbf7 2024-01-23 41: k1_3:flush()
bb2048dbf7 2024-01-23 42: k1_3:close()
bb2048dbf7 2024-01-23 43: end
bb2048dbf7 2024-01-23 44: function d_5.写件_一维(o1, o1_9, o2, o3)
bb2048dbf7 2024-01-23 45: local k1 = table.concat(o1_9, "\n")
bb2048dbf7 2024-01-23 46: if o3 then
bb2048dbf7 2024-01-23 47: k1 = o3(k1)
bb2048dbf7 2024-01-23 48: end
bb2048dbf7 2024-01-23 49: d_5.写件(o1, k1, o2)
bb2048dbf7 2024-01-23 50: end
54cfae3e62 2024-01-23 51: function d_5.删注_月程语_多行注_凡态(o1)
dfd48a1f68 2024-01-23 52: return o1:gsub("%-%-%[%[.-%]%]", "")
dfd48a1f68 2024-01-23 53: end
54cfae3e62 2024-01-23 54: function d_5.删注_月程语_单行注(o1)
6cde949a2c 2024-01-23 55: return o1:gsub("%-%-[^\n]+", "")
dfd48a1f68 2024-01-23 56: end
54cfae3e62 2024-01-23 57: function d_5.删注_lua(o1)
54cfae3e62 2024-01-23 58: o1 = d_5.删注_月程语_多行注_凡态(o1)
54cfae3e62 2024-01-23 59: return d_5.删注_月程语_单行注(o1)
bb2048dbf7 2024-01-23 60: end
bb2048dbf7 2024-01-23 61: function d_5.筛排(o1_9, o1, o2, o3)
bb2048dbf7 2024-01-23 62: local k1_8
bb2048dbf7 2024-01-23 63: local k1_9
bb2048dbf7 2024-01-23 64: k1_9 = {}
bb2048dbf7 2024-01-23 65: for o4 = 1, #o1_9 do
bb2048dbf7 2024-01-23 66: k1_8 = o1(o1_9[o4], o2, o3)
bb2048dbf7 2024-01-23 67: if k1_8 then
bb2048dbf7 2024-01-23 68: k1_9[#k1_9 + 1] = k1_8
bb2048dbf7 2024-01-23 69: end
bb2048dbf7 2024-01-23 70: end
bb2048dbf7 2024-01-23 71: return k1_9
bb2048dbf7 2024-01-23 72: end
bb2048dbf7 2024-01-23 73: function d_5.筛件径(o1, o2)
bb2048dbf7 2024-01-23 74: local k1
bb2048dbf7 2024-01-23 75: local k1_9
bb2048dbf7 2024-01-23 76: k1_9 = {}
bb2048dbf7 2024-01-23 77: for o3 in 简件系库.dir(o1) do
bb2048dbf7 2024-01-23 78: if o3:match(o2 or ".") then
bb2048dbf7 2024-01-23 79: k1_9[#k1_9 + 1] = o1 .. "/" .. o3
bb2048dbf7 2024-01-23 80: end
bb2048dbf7 2024-01-23 81: end
bb2048dbf7 2024-01-23 82: return k1_9
bb2048dbf7 2024-01-23 83: end
bb2048dbf7 2024-01-23 84: function d_5.加前缀(o1, o2)
bb2048dbf7 2024-01-23 85: return o2 .. o1
bb2048dbf7 2024-01-23 86: end
bb2048dbf7 2024-01-23 87: function d_5.加前缀与后缀(o1, o2, o3)
bb2048dbf7 2024-01-23 88: return o2 .. o1 .. o3
bb2048dbf7 2024-01-23 89: end
bb2048dbf7 2024-01-23 90: function d_5.加后缀(o1, o2)
bb2048dbf7 2024-01-23 91: return o1 .. o2
bb2048dbf7 2024-01-23 92: end
bb2048dbf7 2024-01-23 93: function d_5.filterLinesWithCharacter(text, character)
bb2048dbf7 2024-01-23 94: local result = {}
bb2048dbf7 2024-01-23 95: -- 将文本按行拆分为一个行的数组
bb2048dbf7 2024-01-23 96: local lines = {}
bb2048dbf7 2024-01-23 97: for line in text:gmatch("[^\n]+") do
bb2048dbf7 2024-01-23 98: table.insert(lines, line)
bb2048dbf7 2024-01-23 99: end
bb2048dbf7 2024-01-23 100: -- 遍历每一行,检查是否包含目标字符
bb2048dbf7 2024-01-23 101: for i, line in ipairs(lines) do
bb2048dbf7 2024-01-23 102: if line:find(character, 1, true) then
bb2048dbf7 2024-01-23 103: table.insert(result, line)
bb2048dbf7 2024-01-23 104: end
bb2048dbf7 2024-01-23 105: end
bb2048dbf7 2024-01-23 106: return result
bb2048dbf7 2024-01-23 107: end
bb2048dbf7 2024-01-23 108: function d_5.办并说(o1)
bb2048dbf7 2024-01-23 109: print(o1)
bb2048dbf7 2024-01-23 110: os.execute(o1)
bb2048dbf7 2024-01-23 111: end
bb2048dbf7 2024-01-23 112: return d_5