4 ms·
Real regex would be nice. I understand not going full beans with the batteries, but surely a few more wouldn't go amiss? Perhaps a 'battery' for formatting a
by stretchcat 6y ago
Real regex would be nice. I understand not going full beans with the batteries, but surely a few more wouldn't go amiss? Perhaps a 'battery' for formatting a Lua table as a string, since tables are such a big deal in Lua? This would help immensely when debugging scripts during development.
- ziml77 6y agoA built-in function to convert a table to a string would be great. It's not hard to write one myself but tables are so core to the language and printing them is handy for debugging and exploration.
- ufo 6y agoFor more complex string matching tasks that the built-in patterns cannot handle, LPeg might be a good choice. I think it's not likely that something like PCRE-compatible regular expressions would be included in the Lua standard library because PCRE is fairly large, by Lua standards. By the way, for formatting Lua tables for debugging I like using "inspect". (It's not part of the standard library but oh well, that's the whole topic of today's discussion). http://www.inf.puc-rio.br/~roberto/lpeg/ http://www.inf.puc-rio.br/~roberto/lpeg/ https://github.com/kikito/inspect.lua https://github.com/kikito/inspect.lua
- stretchcat 6y agoSure PCRE support would be big, but even posix-style BRE would be a very welcome improvement I think. (As for formatting tables, presently most of my Lua code has been written for mpv which has a builtin utils.to_string(v) for this purpose. In the manpage, this is documented as "only needed because Lua is terrible." I think that's a bit too far, but the frustration this must have caused really comes across.)
- pull_my_finger 6y ago> PCRE support would be big I have to say, once I learned to appreciate the combo of Lua's builtin pattern matching (no not _that_ kind of pattern matching) and LPEG, I really loathe having to use cryptic regexp's in languages like JS. Patterns are enough for most stuff, and when you want to get into more complex patterns, a PEG (LPEG in particular) is much more readable and expressive than a regex that would come out looking like a generated password.