Code: Select all
loc = 'Bruce,, Rusk, WI, USA'
--[[ another:]]
-- loc = ', Valley, Marshall, MN, USA'
local FLD = {}
local idx = 0
for field in loc:gmatch('([^,]+)') do
if field == nil then field = ' ' end
idx = idx + 1
FLD[idx] = field:gsub('^ ', '') or ' '
end
my ADDR and PLAC fields are csv and positionaly important
loc is:
City, township, county, state, nation
as you see, I do not have the township in Bruce but I need to know that it is not there by placing a 'space character' in FLD[2]
I have tried everything I can think of (I am not good at patterns) to capture the situation, but to no avail.
Thanks.