Livid
284.65D
539.49D
V2EX  ›  Lua

关于 Lua 的标准库

  •  
  •   Livid ·
    PRO
    · Mar 28, 2016 · 11447 views
    This topic created in 3721 days ago, the information mentioned may be changed or developed.

    或许是因为 Lua 真的太简洁了,所以很多在其他语言里作为标准库一部分的功能,在 Lua 里都需要自己写。比如:

    • 将一个字符串用空格切割成 table
    • 检查一个元素是否存在于 table 中
    • ……

    所以我比较好奇的是,目前是否有什么比较好的 Lua 库,可以引入之后用来解决这些最常见的问题?

    7 replies    2020-04-10 09:47:42 +08:00
    rock_cloud
        1
    rock_cloud  
       Mar 28, 2016   ❤️ 1
    string.gsub 函数就可以,配合正则表达式,可以实现很多功能。
    clino
        2
    clino  
       Mar 28, 2016   ❤️ 3
    http://lua-users.org/wiki/LibrariesAndBindings 里貌似只看到一个: [Moses](5.x) - Library for tables processing.
    文档在: http://yonaba.github.io/Moses/doc/
    kaixuan1901
        3
    kaixuan1901  
       Mar 28, 2016   ❤️ 2
    kran
        4
    kran  
       Mar 28, 2016   ❤️ 1
    字符串的操作, lpeg 无出其右了。
    saga
        5
    saga  
       Mar 29, 2016
    @kran 同赞 lpeg ,虽然我不会用。
    defmacro
        6
    defmacro  
       Apr 18, 2016
    如果考虑性能的话,另外一个可以考虑的库是 https://github.com/rtsisyk/luafun

    不过这个更多的是在 table 上进行处理,对于 string 本身的处理并不是很全
    Lexo
        7
    Lexo  
       Apr 10, 2020   ❤️ 1
    Openresty,比如你说的分割问题可以用 ngx.re.split 解决
    第二个...是有点头疼...得自己遍历
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   2471 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 41ms · UTC 00:42 · PVG 08:42 · LAX 17:42 · JFK 20:42
    ♥ Do have faith in what you're doing.