[cl-ppcre-devel] Re: Cl-ppcre usage
Sébastien Saint-Sevin
seb-cl-mailist at matchix.com
Thu Sep 30 13:33:40 UTC 2004
Hi Edi & list,
two points :
1) virtuals bugs
2) user hook
1) I feel really stupid : the two behaviours I mentionned in my previous
mails were already corrected in recents releases.
I was using 0.1.3 !!! The reason : the library was so good from its first
releases that I simply forgot to upgrade ;-)
2) More interesting :
I tried a few things to simply implement what I need, ie simple lookup
function to validate a match.
Here is what I came to:
I added a (:FILTER <number> <predicate>) parse-tree S-expr.
It is similar to a (:BACK-REFERENCE <number>) in that it refers to the
:REGISTER defined by <number>.
It is different in that it does not consume any char in the regex string,
but submit the register substring to its predicate to validate or not the
current register match.
So to achieve what I wanted, I just have to encapsulate the parsed tree with
(:SEQUENCE (:REGISTER <parsed-tree>) (:FILTER 1 MY-PREDICATE-SYMBOL))
If I still want to use (parse-string <string>) to build the main part of the
tree, I just need to incf all registers within the parsed-tree by one to
take into account the register I finally add to the tree.
What do you think about all that ?
Cheers,
Sebastien.
> -----Message d'origine-----
> De : cl-ppcre-devel-bounces at common-lisp.net
> [mailto:cl-ppcre-devel-bounces at common-lisp.net]De la part de Edi Weitz
> Envoyé : mercredi 29 septembre 2004 01:19
> À : Sébastien Saint-Sevin
> Cc : cl-ppcre-devel at common-lisp.net
> Objet : [cl-ppcre-devel] Re: Cl-ppcre usage
>
>
> Hi Sébastien!
>
> On Tue, 28 Sep 2004 16:12:21 +0200, Sébastien Saint-Sevin
> <seb at matchix.com> wrote:
>
> > I've got two questions regarding cl-ppcre usage.
> >
> > 1) do-scans
> > I need to use multi-matching within a string so I use do-scans.
> > However, I've got some troubles when I use ^ to force a match at the
> > begining of the string. It's like the start of the string is
> > constantly reinit after each match within the string (and this is
> > not what I want as you already suppose).
> >
> > Is there a way to do it?
>
> I'm not really sure what you want to achieve - maybe an example would
> help. If your search pattern contains ^ then it can only match once,
> right? Have you looked at the m modifier?
>
> > 2) user hook
> > I want to combine regex and some kind of lookup tables (hash-table
> > that stores string). In Michael parker's regex engine, it is
> > possible to give the engine a user hook function that, when a match
> > is found, check it against this user function to finally validate
> > it, otherwise backtrack the matching.
> >
> > How can I do that with CL-PPCRE ? (where do I need to hack the code
> > otherwise ? ;-))
>
> I have plans to implement this in the future but my current workload
> and other projects don't allow me to do that. If you provide a clean
> patch which implements this functionality I'd be glad to integrate
> it. (In my opinion this should only be possible in parse trees,
> though, in order not to break Perl compatibility.)
>
> Cheers,
> Edi.
>
> _______________________________________________
> cl-ppcre-devel site list
> cl-ppcre-devel at common-lisp.net
> http://common-lisp.net/mailman/listinfo/cl-ppcre-devel
>
More information about the Cl-ppcre-devel
mailing list