Regular Expression Help

Questions about the LÖVE API, installing LÖVE and other support related questions go here.
Forum rules
Before you make a thread asking for help, read this.
Post Reply
User avatar
GreenAvoro
Prole
Posts: 4
Joined: Wed Apr 29, 2015 10:25 am

Regular Expression Help

Post 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|||
Last edited by GreenAvoro on Mon May 14, 2018 3:14 am, edited 1 time in total.
bobbyjones
Party member
Posts: 730
Joined: Sat Apr 26, 2014 7:46 pm

Re: Regular Expression Help

Post by bobbyjones »

This page documents how to split in lua.
http://lua-users.org/wiki/SplitJoin
User avatar
ivan
Party member
Posts: 1912
Joined: Fri Mar 07, 2008 1:39 pm
Contact:

Re: Regular Expression Help

Post 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? :)
Post Reply

Who is online

Users browsing this forum: Google [Bot] and 1 guest