Any nicer API around cl-ppcre?

Discussion of Common Lisp
Post Reply
alby
Posts: 7
Joined: Wed May 20, 2009 2:12 am

Any nicer API around cl-ppcre?

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

ramarren
Posts: 613
Joined: Sun Jun 29, 2008 4:02 am
Location: Warsaw, Poland
Contact:

Re: Any nicer API around cl-ppcre?

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

gugamilare
Posts: 406
Joined: Sat Mar 07, 2009 6:17 pm
Location: Brazil
Contact:

Re: Any nicer API around cl-ppcre?

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

findinglisp
Posts: 447
Joined: Sat Jun 28, 2008 7:49 am
Location: Austin, TX
Contact:

Re: Any nicer API around cl-ppcre?

Post by 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: http://code.google.com/p/terse-ppcre/

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: http://common-lisp.net/project/cl-irregsexp/ cl-irregsexp was used to build John Fremlin's fast Lisp-based web server: http://tlug.jp/meetings/2008/11/serving ... andout.pdf
Cheers, Dave
Slowly but surely the world is finding Lisp. http://www.findinglisp.com/blog/

alby
Posts: 7
Joined: Wed May 20, 2009 2:12 am

Re: Any nicer API around cl-ppcre?

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

Post Reply