Carlos
10/8/2015 3:07:00 PM
On 08/10/2015 15:44, Matthew Carter wrote:
> Marco Antoniotti <marcoxa@gmail.com> writes:
>
>> On Thursday, October 8, 2015 at 1:11:04 PM UTC+2, Jim Newton wrote:
>>> Hi WJ, I'd like to read more about this regexp library. Is there
>>> something published about how it works. I'm more interested in its
>>> implementation that its usage.
>>
>> No Jim, you don't want to read more of the WJ-bot. Seriously. DNFTT :)
>>
>> CL-PPCRE should have everything you and Carlos need.
>>
>> Cheers
>> --
>> MA
>
> I may have missed it in the thread, but what's a trivial example of
> named groups with cl-ppcre? (Sorry, too lazy to RTFM, hold my hand
> please :p ).
>
cl-ppcre will give you a list with the named group names at their
corresponding positions when you create a scanner. You can save it and
use it later to retrieve the group contents by position.
Example:
CL-USER> (setf cl-ppcre:*allow-named-registers* t)
T
CL-USER> (cl-ppcre:create-scanner "(a)=(?<a>.), (b)=(?<b>.)")
#<CLOSURE (LAMBDA (STRING CL-PPCRE::START CL-PPCRE::END)
:IN
CL-PPCRE::CREATE-SCANNER-AUX) {100620B5EB}>
(NIL "a" NIL "b")
That's the only support has for named groups. I was hoping a library
that wouldn't make me having to write wrappers for almost all their
functions...
--