To work with lua captures from the command line, I wrote a script:
#!/usr/bin/lua msg = arg[1] or error('No matching pattern!', 2) text = io.read('*a') for str in string.gmatch(text, msg) do io.write(str, '\n') end The only problem is: how to make for forwards all capture results in a row / table? That is, the pattern ()(%S+)() will only return the position of the beginning of the word - 1.