0

I want to replace all occurrences of abc in my string to xyz as below:

The following must be replacd with xyz:

abc with space in either side ,abc abc, abc; abc.

But the following must be left unchanged:

abc as part of any other word like aabcd or abcdef abchaving _ after or before it like abc_ or _abc

I tried the following codes but didn't work out:

string.gsub(str,'%W'.."abc"..'%W', "xyz")

or

string.gsub(str,'[ ,]'.."abc"..'[ ,.;]', "xyz")

is t possible to do so in lua? May you please guide me? regards

Majid NK
  • 311
  • 1
  • 3
  • 16

0 Answers0