Any nicer API around cl-ppcre?

Discussion of Common Lisp

Any nicer API around cl-ppcre?

Postby alby » Fri Jun 19, 2009 5:09 am

cl-ppcre is nice, but is there any API that wraps it in some easier-to-use syntax? I'm looking for something that'd make regexps more fluid to use, as in Ruby and Perl.
Posts: 7
Joined: Wed May 20, 2009 2:12 am

Re: Any nicer API around cl-ppcre?

Postby ramarren » Fri Jun 19, 2009 7:01 am

I don't really see what you mean. The only significant syntax issue with regexps is character escaping (double backslashes), which is solved by cl-interpol, which has a special regexp mode.
Posts: 613
Joined: Sun Jun 29, 2008 4:02 am
Location: Warsaw, Poland

Re: Any nicer API around cl-ppcre?

Postby gugamilare » Fri Jun 19, 2009 8:40 am

You can also use sexps with cl-ppcre to identify regexps instead of strings, which also solves the problem (and they should be much easier to memorize and read as well). As reference, see the method of CREATE-SCANNER that works on parse-trees (roll down the link I provided a little bit and you will see it).
Posts: 406
Joined: Sat Mar 07, 2009 6:17 pm
Location: Brazil

Re: Any nicer API around cl-ppcre?

Postby findinglisp » Fri Jun 19, 2009 9:26 am

Macros, baby. You have everything you need at your fingertips already. If you're doing a lot of regex work, you typically will have a couple of patterns that you are using often and you can just use a simple macro or two to optimize the syntax for those.

That said, terse-ppcre seems to wrap cl-ppcre with a different (better?) syntax:

There is also cl-irregsexp which is a completely different regex implementation that claims to be faster than cl-ppcre, at least on some tests. It also has a different syntax: cl-irregsexp was used to build John Fremlin's fast Lisp-based web server: ... andout.pdf
Cheers, Dave
Slowly but surely the world is finding Lisp.
Posts: 440
Joined: Sat Jun 28, 2008 7:49 am
Location: Austin, TX

Re: Any nicer API around cl-ppcre?

Postby alby » Mon Jun 22, 2009 10:23 am

Thanks all!

I had another look at cl-ppcre's API and I see that it's actually easy to use. It's just the the function/macro names are "weird" (to a Lisp newbie). In fact, I won't even have to write macros to ease things.

(Dave, thanks for the interesting links.)
Posts: 7
Joined: Wed May 20, 2009 2:12 am

Return to Common Lisp

Who is online

Users browsing this forum: Bing [Bot] and 12 guests