Page 1 of 1

Regular Expression Help

Posted: Mon May 14, 2018 3:06 am
by GreenAvoro
This is a problem I'm having within my love2d game, however it's not specifically a love2d problem.

I need the the regex pattern that will allow me to extract the strings in-between the '|||' characters. I'm using string.gmatch().

tile_18.png,-195,-193|||tile_18.png,-194,-193|||tile_18.png,-193,-193|||tile_18.png,-192,-193|||tile_12.png,-195,-192|||tile_12.png,-194,-192|||tile_12.png,-193,-192|||tile_12.png,-192,-192|||tile_6.png,-190,-198|||tile_6.png,-186,-198|||tile_6.png,-184,-196|||tile_6.png,-189,-188|||tile_6.png,-190,-189|||

Re: Regular Expression Help

Posted: Mon May 14, 2018 3:12 am
by bobbyjones
This page documents how to split in lua.
http://lua-users.org/wiki/SplitJoin

Re: Regular Expression Help

Posted: Mon May 14, 2018 8:16 pm
by ivan
The following should work as long as your file names do not contain "|"

Code: Select all

for s in string.gmatch(input, "([^%|]+)") do
  print(s)
end
Why is the input string such a mess in the first place? :)