Boost logo

Boost Users :

From: Greg Ferrar (ferrar_at_[hidden])
Date: 2005-10-28 18:08:14


Hi,

I've been using Boost regexp library forever, and it's great. But I just
grabbed 1.33.0 (trying to get it to compile on 64-bit Windows), and I'm
getting an error I never got before: it refuses to allow this regular
expression:

  [a-z-]

which is supposed to mean "a lower case letter or a dash". Previous
versions of Boost regexp allowed this, and grep allows it, and version
1.33.0 does allow this one:

  [-a-z]

Is this a deliberate restriction? It's causing me lots of problems,
because my application has a lot of existing regular expressions which
use this syntax.

This occurs both on x64 with VC8, and on a pretty standard (and old)
32-bit Linux system.

I've hacked around it horribly for now by adding this to the top of
regcompA (I use the A posix interface exclusively):

  // HACK by GMF to fix problem that [a-z-] is not accepted as valid,
but [-a-z] is. Fix it by moving the
dash.
  char *p = (char*) ptr;
  while (*p) {
    printf("p: %c\n", *p);
    if (*p == '\\')
      p++;
    else if (*p == '[') {
      char *q = p+1;
      while (*q && (*q != ']')) {
        printf("*q: %c\n", *q);
        q++;
      }
      if (*q == ']') {
        q--;
        if (*q == '-') {
          memmove(p+2, p+1, (q-p)-1);
          *(p+1) = '-';
          p = q;
        }
      }
    }
    p++;
  }

but that's very nasty, and probably doesn't work properly anyway, and
I'd sure like to get that out of my production code. Help!

Greg


Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net