Lua Pattern - How get the required string using this lua pattern -
local invoicedata = [[i n v o c e invoice no. : abcdefg125469857 invoice date may 2012 ]]
the pattern using
print (string.match(invoicedata,'\ninvoice date (.-)\n'))
i want fetch string invoice date may12. or 0512.. please help
thanks
instead of matching .-
, more specific , use %w+
(alpha-nums) , %d+
(digits) match month , year.
the script:
local invoicedata = [[i n v o c e invoice no. : abcdefg125469857 invoice date may 2012 ]] month, year = string.match(invoicedata,'invoice%s+date%s+(%w+)%s+%d*(%d%d)') print(month, year)
will print:
may 12
Comments
Post a Comment