【问题标题】:Lua: Remove a character from stringLua:从字符串中删除一个字符
【发布时间】:2021-01-10 04:20:50
【问题描述】:

例如,我将如何从“helloh”中删除 h,使其看起来像“ello”


我不知道还能写什么,但看起来我需要写更多的文字,也许还需要添加一些代码,所以这只是垃圾。

print("junk 1")
print("junk 2")
print("junk 4")

【问题讨论】:

    标签: lua


    【解决方案1】:

    你可以用string.gsub替换字符,gsub代表global subtitusion。

    print(("helloh"):gsub("h", "")) -- replace all instances of `h` with empty string 
    

    【讨论】:

      猜你喜欢
      • 2023-03-14
      • 2019-03-17
      • 1970-01-01
      • 2013-04-30
      • 2013-03-02
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多