Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon.

Pages: 1-

[Lua] Capturing all captures

Name: Anonymous 2006-11-26 22:36

Quick q. How did I get table w/ all captures from string.match() ?

Currently I use something like this:
    c1, c2, c3 = string.match(s, pattern)
    captures = { ["\\1"] = c1, ["\\2"] = c2, ["\\3"] = c3 }
Obviously, this is not how it should be.

Name: Anonymous 2006-11-27 4:06 (sage)

people actually use lua?

Name: Anonymous 2006-11-27 4:39

>>2
Sure, why not ? It's quite nice if you need lightweight scripting language. It seems that it is very popular among game developers ( WoW, Far Cry, Baldur's Gate, Ragnarok, ... ), but some software use it too, like Adobe Lightroom.

I use it to implement caching engine for LightTPD webserver.

Name: Anonymous 2006-11-27 6:07

Lua is very popular among game developers because it's very small, very fast, easy to embed, and very extensible as a language, or so I hear. Because of this, I'm surprised Adobe used it.

Name: Anonymous 2006-11-29 20:35

I'm not sure quite why you're using stuff like ["\\1"] as indices, but if you can deal with numerical indices, you can make it more concise like so:
captures = { string.match(s, pattern) }
In case you were curious, the opposite of this operation is the function unpack, which returns multiple arguments according to the array passed to it:
string.match(unpack( { s, pattern } ))

Name: Anonymous 2006-11-30 14:04

>>1
why don't you use a generic for looping through the results of string.gmatch?

Name: OP 2006-11-30 16:23

>>5
Thank you, that's exactly what I was asking for. I really wasn't expecting anyone to answer this, /prog/ seems to be all about trolling...

>>6
Oh, thats useful too, thanks. I'm still very new to Lua, like a couple of days.

Name: Deep Anal Sex 2011-08-26 13:58

Deep Anal Sex

Name: Anonymous 2011-08-26 14:26

Prog Trek: Deep Anus 9

Name: Sgt.Kabu䓔㼇kiman腕 2012-05-28 21:00

>>11
dubs won this time
dubs won this time
dubs won this time
dubs won this time
dubs won this time
dubs won this time
dubs won this time
dubs won this time
dubs won this time
dubs won this time
dubs won this time
dubs won this time
dubs won this time
dubs won this time
dubs won this time
dubs won this time
dubs won this time
dubs won this time
dubs won this time
dubs won this time
dubs won this time
dubs won this time
dubs won this time
dubs won this time
dubs won this time
dubs won this time
dubs won this time
dubs won this time
dubs won this time
dubs won this time
dubs won this time
dubs won this time
dubs won this time
dubs won this time
dubs won this time
dubs won this time
dubs won this time
dubs won this time
All work and no play makes Jack a dull boy
All work and no play makes Jack a dull boy
All work and no play makes Jack a dull boy
All work and no play makes Jack a dull boy
All work and no play makes Jack a dull boy
All work and no play makes Jack a dull boy
All work and no play makes Jack a dull boy
All work and no play makes Jack a dull boy
All work and no play makes Jack a dull boy
All work and no play makes Jack a dull boy
All work and no play makes Jack a dull boy
All work and no play makes Jack a dull boy
All work and no play makes Jack a dull boy
All work and no play makes Jack a dull boy
All work and no play makes Jack a dull boy
All work and no play makes Jack a dull boy
All work and no play makes Jack a dull boy
All work and no play makes Jack a dull boy
All work and no play makes Jack a dull boy
All work and no play makes Jack a dull boy
All work and no play makes Jack a dull boy
All work and no play makes Jack a dull boy
All work and no play makes Jack a dull boy
All work and no play makes Jack a dull boy

Don't change these.
Name: Email:
Entire Thread Thread List