[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: Patterns: Why are anchors not character classes?
- From: Parke <parke.nexus@...>
- Date: Wed, 15 Jul 2015 18:15:50 -0700
On Wed, Jul 15, 2015 at 5:20 PM, Paul K <paul@zerobrane.com> wrote:
>> Slightly off topic, but since it's been brought up a few times in this thread... Has anyone out there written a "human-readable" patch/wrapper for LPEG? Every time I try to look at a non-trivial example, my brain starts to melt.
>
> There is "re", which gives you access to most (all?) functionality of
> LPEG while following a more familiar syntax. Even though I'm very
> familiar with regexps, I now find LPEG expressions easier to read than
> corresponding "re" scripts, but it's probably a matter of experience.
I enjoy using LPeg's re module extensively.
http://www.inf.puc-rio.br/~roberto/lpeg/re.html
There are some things you cannot do directly in re. For example, back
captures. (As opposed to back references, which can be done in re.)
http://www.inf.puc-rio.br/~roberto/lpeg/#cap-b
Indirectly, you can use LPeg to create a back capture, and then use
that pre-created back capture via the %name syntax in re.
-Parke