Re: [I really need answers to make progress]



Am 24.07.2001 17:13:19 schrieb(en) Pawel Salek:
> On 2001-07-20 17:07 Emmanuel wrote:
[snip]
[Sorry, I did not get your complete discussion...]
> > Another question is about reg. exp : I saw something about using PCRE 
> > for URL parsing, I guess I'll have to use that lib too (when I have
> > time to code reg exp matches :).
> 
> Basically, PCRE is Perl-Compatible Regular Expressions library. You
> don't have to worry about it now: porting things from ordinary RE to
> PCRE is trivial.

Emmanuel, the use of PCRE or "normal" regex routines is absolutely
transparent. If you use only standard stuff in your regular expressions (do
you?), all you need is writing the following lines at the beginning of your .c
file:

#ifdef HAVE_PCRE
#  include <pcreposix.h>
#else
#  include <sys/types.h>
#  include <regex.h>
#endif

That's it. pcreposix.h defines wrapper functions for regcomp, regexec and
regfree, and you need absolutely no further changes in your code. So sit back
and relax...

The improvements of PCRE are

* it is a standard lib, which eliminates some confusion about things which are
implemented differently in GNU, HS, posix... One example is the "beginning of
a word" marker, which is \< in one implementation, [[:<:]] in the next, and
may not work at all (I had this problem during the development of the URL
detection stuff, and there seems to be no reliable way to find out which regex
implementation is actually used). In PCRE, it is (as in PERL) \b, and it
*does* work;

* it is, according to Brian, one of the faster implementations of the regex
library;

* if you want to invest a little more work, you can also use it's i18n
features. This means, that with e.g. LANG=de_DE.ISO-8859-1, all the national
characters are recognised within the [[:alpha:]] class. However, you have to
use the "native" pcre routines in this case (I made a patch for the spell
checker which does exactly this and sent it to the list a few days ago. But
it's not in the cvs yet. Hmmm....)

Cheers,

	Albrecht.


-- 
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    Albrecht Dreß  -  Monschauer Straße 22  -  D-53121 Bonn (Germany)
      Phone (+49) 228 6199571  -  E-Mail albrecht.dress@arcormail.de
_________________________________________________________________________




[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]