lua-users home
lua-l archive

Re: FQDN Pattern/regex LUA help

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


On 2022年12月27日, vale.gua wrote:
> s = os.getenv("HOSTNAME") to catch the FQDN, therefore the result is:
> vimhost-axzh9a.ch.bwww.com
> Is possible, with LUA, to cut from FQDN:
> vimhost-
> and
> .ch.bwww.com
local s = "vimhost-axzh9a.ch.bwww.com"
local h1, h2, h3 = string.match(s, "([^%-]+)%-([^%.]+)%.(.+)")
print(h1, h2, h3)
Best Regards
Hartmut

AltStyle によって変換されたページ (->オリジナル) /