[Date Prev][Date Next][Thread Prev][Thread Next]
- Subject: Re: Feature request: plain option for gsub
- From: Sean Conner <sean@...>
- Date: Thu, 21 Aug 2014 18:02:22 -0400
It was thus said that the Great Jonas Thiem once stated:
> Alternatively, I'm also happy for easier solutions to get this
> behavior of gsub if this is already possible in an easier way that I
> haven't seen.
You could try the following:
lpeg = require "lpeg"
local trans = lpeg.Cs(((lpeg.P(this) / that) + lpeg.P(1))^0)
print(replace("100% efficiency with 20% effort","%"," per cent"))
Yes, it has a dependency on LPeg. But it's simple, and it works as
expected, without any problems of escaping "special" characters.