I have a line like this:
[13:41:25] [100:Devnull]: 01:41:20, 13:41:21> |Hunit:Player-3693-07420299:DevnullYour [Chimaera Shot] hit |Hunit:Creature-0-3693-1116-3-87318-0000881AC4:Dungeoneer Training DummyDungeoneer Training Dummy 33265 Nature.
In case you are interested, this is from World of Warcraft.
I would like to end up with something like this:
[13:41:25] [100:Devnull]: 01:41:20, 13:41:21> Your [Chimaera Shot] hit Dungeoneer Training Dummy 33265 Nature.
If you notice, "Dummoneer Training Dummy" is printed twice. I managed to get rid of the first part of "| Hunit" with something like this:
str = "[13:41:25] [100:Devnull]: 01:41:20, 13:41:21> |Hunit:Player-3693-07420299:DevnullYour [Chimaera Shot] hit |Hunit:Creature-0-3693-1116-3-87318-0000881AC4:Dungeoneer Training DummyDungeoneer Training Dummy 33265 Nature." str = string.gsub(str, "|Hunit:.*:.*Your", "Your")
What returns this:
print(str)
Then I add a second gsub:
str = string.gsub(str, "|Hunit:.*:", "") print(str)
But the double line "Dungeineer Training Dummy" is repeating, obviously.
How can I get rid of a duplicate string? This line can be anything, in this case "Dungeineer Training Dummy", but it can be the name of any other target.
lua world-of-warcraft lua-patterns
user3209270
source share