lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


Hi Emeka


for i = 1, mystringlen do
 dosomething(mystring.sub(i,i))
end
Is there a better way of doing the above? If yes, please throw it to me :)

possibly:
for c in mystring:gmatch('.') do
    dosomething(c)
end

--
Oliver


Am 31.10.2014 um 18:33 schrieb Emeka:
Hello All,


I have some issues with string manipulation that I would want you to help me out with:


mystring = "google+facebook"

mysringlen = string.len(mystring)

for i = 1, mystringlen do
 dosomething(mystring.sub(i,i))
end

Is there a better way of doing the above? If yes, please throw it to me :)


I also wanted to do some comparison :

if mystring.sub(i,i) == ' " '  then .... end It is not comparing at all ,and this also failed.

mystring.sub(i,i)  == ' ' ' ..


Regards, \Emeka


--
Satajanus  Nig. Ltd