|
| 28 Feb 2016 02:01 PM |
Me error m8 " for i in string.gmatch(testString, "%S+") do -- Getting t:4: bad argument #1 to 'find' (string expected, got nil)"
n' me c0de m8
testString = "cats d0gs dsjodajodjsalkdsaj23dsh GOTTMITTSUNS"
function check(strng) local test = string.find(strng, "%p or %d%") if not test then return true end print('test' .. test) end function manipulateString(strng) local words = {} for i in string.gmatch(testString, "%S+") do -- Getting the indivdual words table.insert(words, i) end local longestWord = nil for i,v in pairs(words) do if check(v)then if longestWord then -- Comparing with current record print(v .. " " .. longestWord) if string.len(v) > string.len(longestWord) then print 'Didn"t error!' longestWord = v end else longestWord = v end else print('rejected ' .. v) end end end
manipulateString(testString) |
|
|
| Report Abuse |
|
| |
| |