string.gsub bug?

And reason why this would work:

[lua]propPrice = string.gsub( “Tap!Here”, “!”, " " )
print ( "propPrice "…propPrice )[/lua]

to correctly print “Tap Here” but this:

[lua]propPrice = string.gsub( “Tap$Here”, “$”, " " )
print ( "propPrice "…propPrice )[/lua]

prints “Tap$Here” instead?

[import]uid: 96383 topic_id: 25610 reply_id: 325610[/import]

Try this
[lua]propPrice = string.gsub( “Tap$Here”, “%$”, " " )
print ( "propPrice "…propPrice )[/lua]
According to Lua docs

Some characters, called magic characters, have special meanings when used in a pattern. The magic characters are
( ) . % + - * ? [^ $
The character %´ works as an escape for those magic characters. So, '%.' matches a dot; '%%' matches the character %´ itself. You can use the escape `%´ not only for the magic characters, but also for all other non-alphanumeric characters. When in doubt, play safe and put an escape.
[import]uid: 64174 topic_id: 25610 reply_id: 103506[/import]

Wow thanks Satheesh, perfect. Lua docs - who knew? :slight_smile: [import]uid: 96383 topic_id: 25610 reply_id: 103531[/import]