[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: Replace specific comma's in a string.
- From: Andrew Gierth <andrew@...>
- Date: Sat, 10 Feb 2018 11:53:42 +0000
>>>>> "albertmcchan" == albertmcchan <albertmcchan@yahoo.com> writes:
albertmcchan> just curious, what will lpeg re pattern look like ?
This version is given as an example in the re docs:
record = re.compile[[
record <- {| field (',' field)* |} (%nl / !.)
field <- escaped / nonescaped
nonescaped <- { [^,"%nl]* }
escaped <- '"' {~ ([^"] / '""' -> '"')* ~} '"'
]]
though of course this processes only one record at a time (and assumes
that newline conversion has already been done; the RFC's definition is
for use in MIME bodies with canonical CRLF newlines).
--
Andrew.