14ff7a9f5f 2024-01-24 1: package.path = [[.\lib_lua\?.lua;]] .. package.path
14ff7a9f5f 2024-01-24 2: package.cpath = [[.\lib_dll\?.dll;]] .. package.cpath
6cde949a2c 2024-01-23 3: local 字集码互转库 = require("u8_to_a")
bb2048dbf7 2024-01-23 4: local d_5 = {}
bb2048dbf7 2024-01-23 5: local 简件系库 = require("lfs")
14ff7a9f5f 2024-01-24 6: --~ function _G.require_u8(modname)
14ff7a9f5f 2024-01-24 7: --~ return require(字集码互转库.u8_to_a(modname))
14ff7a9f5f 2024-01-24 8: --~ end
bb2048dbf7 2024-01-23 9: do
bb2048dbf7 2024-01-23 10: local k1 = 0
bb2048dbf7 2024-01-23 11: function _G.递增示()
bb2048dbf7 2024-01-23 12: k1 = k1 + 1
bb2048dbf7 2024-01-23 13: print(k1)
bb2048dbf7 2024-01-23 14: end
bb2048dbf7 2024-01-23 15: end
bb2048dbf7 2024-01-23 16: --~ do
bb2048dbf7 2024-01-23 17: --~ local k1 = os.execute
bb2048dbf7 2024-01-23 18: --~ function _G.os.execute(command)
6cde949a2c 2024-01-23 19: --~ return k1(字集码互转库.u2a(command))
bb2048dbf7 2024-01-23 20: --~ end
bb2048dbf7 2024-01-23 21: --~ end
bb2048dbf7 2024-01-23 22: function d_5.读件(o1, o2)
bb2048dbf7 2024-01-23 23: local k1
bb2048dbf7 2024-01-23 24: local k1_3
bb2048dbf7 2024-01-23 25: k1_3 = io.open(o1, o2 or "r")
bb2048dbf7 2024-01-23 26: k1 = k1_3:read("a")
bb2048dbf7 2024-01-23 27: k1_3:flush()
bb2048dbf7 2024-01-23 28: k1_3:close()
bb2048dbf7 2024-01-23 29: return k1
bb2048dbf7 2024-01-23 30: end
bb2048dbf7 2024-01-23 31: function d_5.读件排(o1_9, o1)
bb2048dbf7 2024-01-23 32: local k1_9
bb2048dbf7 2024-01-23 33: k1_9 = {}
bb2048dbf7 2024-01-23 34: for o2 = 1, #o1_9 do
bb2048dbf7 2024-01-23 35: k1_9[#k1_9 + 1] = d_5.读件(o1_9[o2], o1)
bb2048dbf7 2024-01-23 36: end
bb2048dbf7 2024-01-23 37: return k1_9
bb2048dbf7 2024-01-23 38: end
bb2048dbf7 2024-01-23 39: function d_5.写件(o1, o2, o3)
bb2048dbf7 2024-01-23 40: local k1_3
bb2048dbf7 2024-01-23 41: k1_3 = io.open(o1, o3 or "w")
bb2048dbf7 2024-01-23 42: k1_3:write(o2)
bb2048dbf7 2024-01-23 43: k1_3:flush()
bb2048dbf7 2024-01-23 44: k1_3:close()
bb2048dbf7 2024-01-23 45: end
bb2048dbf7 2024-01-23 46: function d_5.写件_一维(o1, o1_9, o2, o3)
bb2048dbf7 2024-01-23 47: local k1 = table.concat(o1_9, "\n")
bb2048dbf7 2024-01-23 48: if o3 then
bb2048dbf7 2024-01-23 49: k1 = o3(k1)
bb2048dbf7 2024-01-23 50: end
bb2048dbf7 2024-01-23 51: d_5.写件(o1, k1, o2)
bb2048dbf7 2024-01-23 52: end
07246ed20a 2024-01-24 53: function d_5.删制表符(o1)
07246ed20a 2024-01-24 54: return o1:gsub("\t", "")
07246ed20a 2024-01-24 55: end
07246ed20a 2024-01-24 56: --~ function d_5.删空白字(o1)
07246ed20a 2024-01-24 57: --~ return o1:gsub("%s", "")
14ff7a9f5f 2024-01-24 58: --~ end
07246ed20a 2024-01-24 59: --~ function d_5.删空格与制表符(o1)
07246ed20a 2024-01-24 60: --~ o1 = d_5.删空格(o1)
07246ed20a 2024-01-24 61: --~ return d_5.删制表符(o1)
07246ed20a 2024-01-24 62: --~ end
0243e12f54 2024-01-23 63: function d_5.文转排(text)
0243e12f54 2024-01-23 64: local lines = {}
0243e12f54 2024-01-23 65: for line in text:gmatch("[^\n]+") do
0243e12f54 2024-01-23 66: table.insert(lines, line)
0243e12f54 2024-01-23 67: end
0243e12f54 2024-01-23 68: return lines
0243e12f54 2024-01-23 69: end
7ba1ff2268 2024-01-23 70: function d_5.删前缀(o1, o2)
7ba1ff2268 2024-01-23 71: if o1:find(o2, 1, true) then
7ba1ff2268 2024-01-23 72: return o1:sub(#o2 + 1)
7ba1ff2268 2024-01-23 73: end
7ba1ff2268 2024-01-23 74: end
7ba1ff2268 2024-01-23 75: function d_5.删后缀(o1, o2)
7ba1ff2268 2024-01-23 76: if o1:find(o2, -1, true) then
7ba1ff2268 2024-01-23 77: return o1:sub(1, #o1 - #o2)
7ba1ff2268 2024-01-23 78: end
eca49ddcf5 2024-01-23 79: end
14ff7a9f5f 2024-01-24 80: --~ function d_5.删空行_不虑首末态(o1)
14ff7a9f5f 2024-01-24 81: --~ return o1:gsub("\n+", "\n")
14ff7a9f5f 2024-01-24 82: --~ end
14ff7a9f5f 2024-01-24 83: --~ function d_5.删空行(o1)
14ff7a9f5f 2024-01-24 84: --~ o1 = d_5.删空行_不虑首末态(o1)
14ff7a9f5f 2024-01-24 85: --~ o1 = d_5.删前缀(o1, "\n")
14ff7a9f5f 2024-01-24 86: --~ return d_5.删后缀(o1, "\n")
14ff7a9f5f 2024-01-24 87: --~ end
07246ed20a 2024-01-24 88: function d_5.删空格(o1)
07246ed20a 2024-01-24 89: return o1:gsub(" ", "")
07246ed20a 2024-01-24 90: end
bb2048dbf7 2024-01-23 91: function d_5.筛排(o1_9, o1, o2, o3)
bb2048dbf7 2024-01-23 92: local k1_8
bb2048dbf7 2024-01-23 93: local k1_9
bb2048dbf7 2024-01-23 94: k1_9 = {}
bb2048dbf7 2024-01-23 95: for o4 = 1, #o1_9 do
bb2048dbf7 2024-01-23 96: k1_8 = o1(o1_9[o4], o2, o3)
bb2048dbf7 2024-01-23 97: if k1_8 then
bb2048dbf7 2024-01-23 98: k1_9[#k1_9 + 1] = k1_8
bb2048dbf7 2024-01-23 99: end
bb2048dbf7 2024-01-23 100: end
bb2048dbf7 2024-01-23 101: return k1_9
bb2048dbf7 2024-01-23 102: end
07246ed20a 2024-01-24 103: function d_5.筛文(o1, o2, o3)
bb2048dbf7 2024-01-23 104: local k1_9
bb2048dbf7 2024-01-23 105: k1_9 = {}
07246ed20a 2024-01-24 106: for o4 in o2(o1, o3) do
14ff7a9f5f 2024-01-24 107: k1_9[#k1_9 + 1] = o4
bb2048dbf7 2024-01-23 108: end
bb2048dbf7 2024-01-23 109: return k1_9
bb2048dbf7 2024-01-23 110: end
07246ed20a 2024-01-24 111: function d_5.留文(o1, o2, o3, o4)
07246ed20a 2024-01-24 112: if o1:find(o2 or ".", o3, o4) then
14ff7a9f5f 2024-01-24 113: return o1
14ff7a9f5f 2024-01-24 114: end
14ff7a9f5f 2024-01-24 115: end
14ff7a9f5f 2024-01-24 116: function d_5.筛件径(o1, o2)
14ff7a9f5f 2024-01-24 117: local k1_9
07246ed20a 2024-01-24 118: k1_9 = d_5.筛文(o1, 简件系库.dir)
14ff7a9f5f 2024-01-24 119: k1_9 = d_5.筛排(k1_9, d_5.加前缀, o1 .. "/")
14ff7a9f5f 2024-01-24 120: return d_5.筛排(k1_9, d_5.留文, o2)
14ff7a9f5f 2024-01-24 121: end
07246ed20a 2024-01-24 122: --~ function d_5.筛单行等式(o1)
07246ed20a 2024-01-24 123: --~ return 常用库.捕排(string.gmatch, o1, "[^\n= \t]+")
07246ed20a 2024-01-24 124: --~ end
07246ed20a 2024-01-24 125: function d_5.捕非空单行(o1)
07246ed20a 2024-01-24 126: return 常用库.捕排(string.gmatch, o1, "[^\n]+[\n]?")
07246ed20a 2024-01-24 127: end
07246ed20a 2024-01-24 128: function d_5.排转对(o1_12, o1)
07246ed20a 2024-01-24 129: local k1_5
07246ed20a 2024-01-24 130: local k1_11
07246ed20a 2024-01-24 131: k1_11 = {}
07246ed20a 2024-01-24 132: for o2 = 1, #o1_12, o1 + 1 do
07246ed20a 2024-01-24 133: k1_5 = {}
07246ed20a 2024-01-24 134: for o3 = 1, o1 do
07246ed20a 2024-01-24 135: k1_5[o3] = o1_12[o2 + o3]
07246ed20a 2024-01-24 136: end
07246ed20a 2024-01-24 137: k1_11[ o1_12[o2] ] = k1_5
07246ed20a 2024-01-24 138: end
07246ed20a 2024-01-24 139: return k1_11
07246ed20a 2024-01-24 140: end
bb2048dbf7 2024-01-23 141: function d_5.加前缀(o1, o2)
bb2048dbf7 2024-01-23 142: return o2 .. o1
bb2048dbf7 2024-01-23 143: end
bb2048dbf7 2024-01-23 144: function d_5.加后缀(o1, o2)
bb2048dbf7 2024-01-23 145: return o1 .. o2
bb2048dbf7 2024-01-23 146: end
bb2048dbf7 2024-01-23 147: function d_5.filterLinesWithCharacter(text, character)
bb2048dbf7 2024-01-23 148: local result = {}
0243e12f54 2024-01-23 149: local lines = d_5.文转排(text)
bb2048dbf7 2024-01-23 150: -- 遍历每一行,检查是否包含目标字符
bb2048dbf7 2024-01-23 151: for i, line in ipairs(lines) do
bb2048dbf7 2024-01-23 152: if line:find(character, 1, true) then
bb2048dbf7 2024-01-23 153: table.insert(result, line)
bb2048dbf7 2024-01-23 154: end
bb2048dbf7 2024-01-23 155: end
bb2048dbf7 2024-01-23 156: return result
bb2048dbf7 2024-01-23 157: end
07246ed20a 2024-01-24 158: function d_5.办令(o1)
bb2048dbf7 2024-01-23 159: print(o1)
bb2048dbf7 2024-01-23 160: os.execute(o1)
07246ed20a 2024-01-24 161: end
07246ed20a 2024-01-24 162: function d_5.在前后加英文双引号(o1)
07246ed20a 2024-01-24 163: return [["]] .. o1 .. [["]]
14ff7a9f5f 2024-01-24 164: end
14ff7a9f5f 2024-01-24 165: --~ function d_5.筛单行等式_左右值态(o1)
14ff7a9f5f 2024-01-24 166: --~ local k1_11
14ff7a9f5f 2024-01-24 167: --~ k1_11 = {}
14ff7a9f5f 2024-01-24 168: --~ for o2 in k1_11:gmatch("[^\n= \t]+") do
14ff7a9f5f 2024-01-24 169: --~ table.insert(k1_11, o2)
14ff7a9f5f 2024-01-24 170: --~ end
14ff7a9f5f 2024-01-24 171: --~ return o2
14ff7a9f5f 2024-01-24 172: --~ end
bb2048dbf7 2024-01-23 173: return d_5