September 2017 Update
This commit is contained in:
parent
bba7bfd280
commit
ba8067c3b7
14570 changed files with 153136 additions and 63871 deletions
|
|
@ -1,10 +0,0 @@
|
|||
require"re"
|
||||
|
||||
record = re.compile[[
|
||||
record <- ( <field> (',' <field>)* ) -> {} (%nl / !.)
|
||||
field <- <escaped> / <nonescaped>
|
||||
nonescaped <- { [^,"%nl]* }
|
||||
escaped <- '"' {~ ([^"] / '""' -> '"')* ~} '"'
|
||||
]]
|
||||
|
||||
print(unpack(record:match"hello,how,are,you,today"))
|
||||
|
|
@ -1,10 +0,0 @@
|
|||
str = "Hello,How,Are,You,Today"
|
||||
|
||||
tokens = {}
|
||||
for w in string.gmatch( str, "(%a+)" ) do
|
||||
tokens[#tokens+1] = w
|
||||
end
|
||||
|
||||
for i = 1, #tokens do
|
||||
print( tokens[i] )
|
||||
end
|
||||
|
|
@ -1,11 +0,0 @@
|
|||
str = "Hello|How|Are|You||Today"
|
||||
|
||||
tokens = {}
|
||||
for w in string.gmatch( str, "([^|]*)|?" ) do
|
||||
tokens[#tokens+1] = w
|
||||
end
|
||||
table.remove(tokens)--pops off the last empty value, because without doing |? we lose the last element.
|
||||
|
||||
for i = 1, #tokens do
|
||||
print( tokens[i] )
|
||||
end
|
||||
Loading…
Add table
Add a link
Reference in a new issue