PDA

View Full Version : Don't know how to explain this ( getting data )


cdlink14
02-18-2009, 02:13 PM
Ok firstly using this as an example... ( Posted by Paul186 here = >> Clicky << (http://www.indigorose.com/forums/showpost.php?p=134224&postcount=3)

1. HTTP.Download("http://www.ipchicken.com/", _TempFolder .. "\\tempfile", 2. MODE_TEXT);
3. error = Application.GetLastError();
4. if (error == 0) then
5. page = TextFile.ReadToString(_TempFolder .. "\\tempfile");
6. File.Delete(_TempFolder .. "\\tempfile", false, false, true);
7. ip = string.sub(page, string.find(page, '%d+%.%d+%.%d+%.%d+'));
8. if (ip ~= nil) then
9. Dialog.Message("IP Address","Your public IP address is '" .. ip .. "'.");
10. else
11. Dialog.Message("IP Address","Not found");
12. end
13. else
14. Dialog.Message("Error", _tblErrorMessages[error], MB_OK,
15. MB_ICONEXCLAMATION);
16. end


From what I can gather on line 7. The '%d+%' is used to find a set of numbers.

What would I do to find a set of letters?

If possible could someone show me by making an example using this test url

http://server123.test.com/download/654321/made up file.rar.001

I hope this is possible.
Thanks for any help,

CDLINK14

Ulrich
02-18-2009, 04:04 PM
This is a regular expression, or a pattern, like it is called in Lua.
You find documentation here (http://www.lua.org/manual/5.0/manual.html#5.3), but is not the most easy stuff to understand.

Ulrich

cdlink14
02-20-2009, 11:07 AM
This is a regular expression, or a pattern, like it is called in Lua.
You find documentation here (http://www.lua.org/manual/5.0/manual.html#5.3), but is not the most easy stuff to understand.

Ulrich

Ok I've managed to get the first bit of the code done, but now it's a case of how do I do the rest of the code?

( Bold code is part I've figured out so far )
http://server123.test.com/download/654321/made up file.rar.001

Now what about the last part? The file/filename, since i'm effectively making a download manager. The files length could be anything, could contain a number of any characters, a wide selection of ".", etc