lua 파일 이름과 확장자 가져오기
4669 단어 lua
local str = "aaa.bbb.bbb.txt"
--
function getFileName(str)
local idx = str:match(".+()%.%w+$")
if(idx) then
return str:sub(1, idx-1)
else
return str
end
end
--
function getExtension(str)
return str:match(".+%.(%w+)$")
end
ngx.say(" :"..str)
ngx.say("====================")
ngx.say(" :"..getFileName(str))
ngx.say("====================")
ngx.say(" :"..getExtension(str))
URL 디코딩, 디코딩
--
function decodeURI(s)
s = string.gsub(s, '%%(%x%x)', function(h) return string.char(tonumber(h, 16)) end)
return s
end
--
function encodeURI(s)
s = string.gsub(s, "([^%w%.%- ])", function(c) return string.format("%%%02X", string.byte(c)) end)
return string.gsub(s, " ", "+")
end
이 내용에 흥미가 있습니까?
현재 기사가 여러분의 문제를 해결하지 못하는 경우 AI 엔진은 머신러닝 분석(스마트 모델이 방금 만들어져 부정확한 경우가 있을 수 있음)을 통해 가장 유사한 기사를 추천합니다:
Neovim - exrc.nvim을 사용한 프로젝트 로컬 구성당신은 물어볼 수 있습니다. 일반적으로 Neovim 구성은 단일 위치에 있습니다: ~/.config/nvim . 해당 프로젝트에서 작업할 때 다른 테마를 설정하거나 특정 프로젝트에 대한 LSP 서버의 동작을 조정할 ...
텍스트를 자유롭게 공유하거나 복사할 수 있습니다.하지만 이 문서의 URL은 참조 URL로 남겨 두십시오.
CC BY-SA 2.5, CC BY-SA 3.0 및 CC BY-SA 4.0에 따라 라이센스가 부여됩니다.