I have the code
string = string:gsub("- - ", "= ")
to take the string
| - - |
and turn it into
| = |
but it always comes out as
| = = |
and I don't know how to fix it.
I have the code
string = string:gsub("- - ", "= ")
to take the string
| - - |
and turn it into
| = |
but it always comes out as
| = = |
and I don't know how to fix it.
Try this pattern
string.gsub("|--||--||--|--|", "%-%-", '=')
Your attempt does not work because - is a magic pattern in string formatting which is described in the wiki as match as few of the preceding character class as possible, since you need to replace the - character instead, you need to use the % operator which turns any special character after it into just a character.
This discussion is preserved as it was. New answers, comments, and votes are closed.
1 comment
I had tried "%-" but didn't consider the fact that it needed to be applied to all of them. Thank you!