Welcome to the Indigo Rose Software discussion forums! You will need to sign up for a forum account and login before you can post. Need help? View the Forum FAQ.
DOH! forget the above - I was looking at the debug window and didn't realise the table was already renewed - I forgot to add this to the top of the code:
Currently I have this code to search for strings - but every time it runs I need to clear the table off all entries, I can't find this command in the tables - so I guess I need to use some sort of table entry remove - how do I clear the entire table though:
Code:
target_table = {}; --Creates a table whose values are empty
mystring = "The quick brown <span>192.168.100.10</span> fox jumped over the lazy dogs <span>192.168.100.20</span>yes that dog was lazy<span>192.168.100.30</span> he was <span>192.168.100.40</span>"
startposition = "0"
find1 = string.match(mystring, "<span>" .. '[0-9]+.[0-9]+.[0-9]+.[0-9]+', startposition) --find the ip address in a string
if find1 == nil then
Dialog.Message("Notice", "no string found", MB_OK, MB_ICONINFORMATION, MB_DEFBUTTON1);
elseif find1 ~= nil then
strip1 = String.Replace(find1, "<span>", "", false); -- remove <span> from the string so we are left with the IP
result1 = String.Find(mystring, find1, 1, false); --get the start position of the IP
nextposition = result1+1 --store the found address then add 1 so we can find the next ip address from this position
Table.Insert(target_table, Table.Count(target_table)+1, strip1);
end
Debug.ShowWindow(true);
while( find1 ~= nil)
do
find1 = string.match(mystring, "<span>" .. '[0-9]+.[0-9]+.[0-9]+.[0-9]+', nextposition) --find the ip address in a string
if find1 == nil then
--do nothing
elseif find1 ~= nil then
strip1 = String.Replace(find1, "<span>", "", false); -- remove <span> from the string so we are left with the IP
result1 = String.Find(mystring, find1, 1, false); --get the start position of the IP
nextposition = result1+1 --store the found address then add 1 so we can find the next ip address from this position
Table.Insert(target_table, Table.Count(target_table)+1, strip1);
end
end
for x,y in pairs(target_table) do
Debug.Print("Index "..x.." = "..y.."\r\n");
end
Leave a comment: