News : The level of daily SPAM has reached insane proportions, all registrations are now manual. I ask you to send me an e-mail (john (at) murga (dot) org), to confirm that you want me to create an account for you.


Post Reply  Post Thread 
match one of three possible substrings?
Author Message
mikshaw
Senior Member
****


Posts: 522
Group: Registered
Joined: Apr 2007
Status: Offline
Reputation: 5
Post: #1
RE: match one of three possible substrings?

I made some apparent progress using a nested loop, although I'm not sure that it is truly progress in the sense of processor/memory usage

Code:
allfiles=murgaLua.readDirectory(realdatadir)
imgtype = { "png", "jpg", "gif" }
for i=1,table.getn(allfiles) do
for t=1,table.getn(imgtype) do
if string.find(allfiles[i],"%."..imgtype[t].."$") then
print('<img src="'..datadir..title..'/'..allfiles[i]..'" alt="'..allfiles[i]..'"/>')
end
end
end


for comparison, here's the same thing done with multiple string searches:

Code:
allfiles=murgaLua.readDirectory(realdatadir)
for i=1,table.getn(allfiles) do
if string.find(allfiles[i],"%.png$") or string.find(allfiles[i],"%.jpg$") or string.find(allfiles[i],"%.gif$") then
print('<img src="'..datadir..title..'/'..allfiles[i]..'" alt="'..allfiles[i]..'"/>')
end
end

06-11-2007 03:20 AM
Find all posts by this user Quote this message in a reply
Post Reply  Post Thread 

Messages In This Thread
RE: match one of three possible substrings? - mikshaw - 06-11-2007 03:20 AM

View a Printable Version
Send this Thread to a Friend
Subscribe to this Thread | Add Thread to Favorites

Forum Jump: