[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.lisp

Regexp library with support for named groups?

Carlos

10/7/2015 1:45:00 PM

Is there a regexp library with support for named groups?

For example, after matching the regexp "a=(?<a>.)" with the string
"a=1", I want to be able to get the "1" using "a" or :a.

--
6 Answers

Jim Newton

10/8/2015 11:11:00 AM

0

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.

Marco Antoniotti

10/8/2015 1:23:00 PM

0

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

Matthew Carter

10/8/2015 1:44:00 PM

0

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 ).

--
Matthew Carter (m@ahungry.com)
http://a...

Carlos

10/8/2015 3:07:00 PM

0

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...

--

Jim Newton

10/8/2015 3:58:00 PM

0

Unfortunately, according to Edi, theres no documentation or papers written on the cl-ppcre implementation, which is what I'd be interested in. There are several theoretical questions I'd
like to investigate.

I'm going to dive into the source code.

Zach Beane

10/8/2015 4:47:00 PM

0

Jim Newton <jimka.issy@gmail.com> writes:

> Unfortunately, according to Edi, theres no documentation or papers
> written on the cl-ppcre implementation, which is what I'd be
> interested in. There are several theoretical questions I'd like to
> investigate.
>
> I'm going to dive into the source code.

The source code is interesting, and I found it fairly straightforward,
if dense.

Zach