Purpose: I started this page because there are things which I have not yet figured out how to do, or do well, in Lua --jcw
Tcl's "regexp": in Tcl, one can use regular expressions to disect a string into several components and place the results in variables, like so:
regexp {^http://([^/])(.*)$} http://site.com/path/to/file - site path
The result is sort of like doing
site, path = 'site.com', '/path/to/file'
What's the way to do this in Lua without having to write code that sets up a table, then gsub into a function with an upvalue and two assignments?
Try this:
x, x, site, path = strfind(url, "^http://([^/]*)(.*)$")
--John
Last modified
2001-05-25
2001-05-25
(210.226.101.5)
Note: you are looking at
the snapshot of an old wiki
- much of this information
is likely to be very outdated
