9

I am trying to remove '$' signs from a string, but I am guessing it is some special char? I am extremely new to lua (just started coding in it today). From my understanding this should work and does for other chars string.gsub(line,'$','').

4

1 回答 1

13

是的,这是模式匹配的特殊字符。您需要使用%符号对其进行转义。

local s = 'asdf$erer$iiuq'
print(s:gsub('%$', ''))

> asdfereriiuq  2
于 2013-09-13T16:50:00.633 回答