View Single Post
11-11-05, 03:19 PM   #2
Littlejohn
A Warpwood Thunder Caller
AddOn Author - Click to view addons
Join Date: Jun 2005
Posts: 90
text = "1, 2, 3, 4"

_, _, a, b, c, d = string.find(text, "(%d+), (%d+), (%d+), (%d+)")

That is probably too finicky for use in the real world -- it won't match if there are extra spaces around the commas for example. This allows any number of spaces:

_, _, a, b, c, d = string.find(text, "(%d+)%s*,%s*(%d+)%s*,%s*(%d+)%s*,%s*(%d+)")

That's getting complicated enough that you may want to build up the pattern string.rep:

_, _, a, b, c, d = string.find(text, string.rep("(%d+)%s*,%s*", 3) .. "(%d+)")
  Reply With Quote