Reputation: 169
I'm writing logging library for Lua, which actually is something like rewrite & bundle of some npm modules (like log-update, chalk, etc.). I want to get true width of string, so I need to strip ANSI escape codes from it. I found npm module that provides regexp for it. But I don't understand how to match these characters in Lua via Lua patterns. Can you help me to write pattern, which does it?
Upvotes: 3
Views: 1385
Reputation: 169
text = string.gsub(text, "[\27\155][][()#;?%d]*[A-PRZcf-ntqry=><~]", "")
Thanks to Egor Skriptunoff!
Upvotes: 5