[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: Matching a character or the end of a line/string
- From: Daurnimator <quae@...>
- Date: Fri, 29 Jun 2012 08:34:52 +1000
On 29 June 2012 08:07, Geoff Leyland <geoff_leyland@fastmail.fm> wrote:
> Hi,
>
> When you're parsing csv files, it would be useful to look for the end of a field with the pattern "[,$]" so that you can find the end of the last field as well as the ends of the previous fields. Trouble is, this doesn't seem to work. Can anyone tell me what I'm missing?
>
> (I looked at [1] and as far as I can tell, that code expects the last field to end with a comma)
>
> Cheers,
> Geoff
>
> [1] http://lua-users.org/wiki/CsvUtils
>
>
Yes using $ or ^ in a class would be useful, but sadly not possible.
You can however use the frontier pattern, it'll match the start or end
of a string as a null byte.
So you can use %f[,%z]
See the 5.2 manual for more info.