This is a read-only snapshot of the ComputerCraft forums, taken in April 2020.
PixelFox's profile picture

Parse Line to Words

Started by PixelFox, 28 July 2015 - 09:58 PM
PixelFox #1
Posted 28 July 2015 - 11:58 PM
I've been working on a function called "parse(_line)", but NOTHING I've done works.
Any suggestions?
KingofGamesYami #2
Posted 29 July 2015 - 12:19 AM
I'm unsure of what you want, do you want a sentence separated into words?


local function parse( str )
  local t = {}
  for word in str:gmatch( "%S+" ) do
    t[ #t + 1 ] = word
  end
  return t
end
PixelFox #3
Posted 29 July 2015 - 01:13 AM
I'm unsure of what you want, do you want a sentence separated into words?


local function parse( str )
  local t = {}
  for word in str:gmatch( "%S+" ) do
	t[ #t + 1 ] = word
  end
  return t
end
Thanks!