why this RE failed?

why this RE failed?

Post by Sam Wu » Sat, 11 May 2002 02:31:49



Following is a sample C code:

#include <regex.h>

const char *test_log = "block out on tun0: 208.167.249.251.1247 >
216.136.175.99.80: ";

const char *test_patterns = "(block|pass) (out|in) on ([a-z]+[0-9]):
([0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}) >
([0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]
{1,3}): ";

tried to match the test_patterns and test_log result failed.
Does any one know what is wrong with the RE pattern I defined for the
test_patterns variable?

Thanks
Sam

 
 
 

why this RE failed?

Post by Sam Wu » Sat, 11 May 2002 02:33:19




Following is a sample C code:

 #include <regex.h>

const char *test_log = "block out on tun0: 208.167.249.251.1247 >
216.136.175.99.80: ";
 const char *test_patterns = "(block|pass) (out|in) on ([a-z]+[0-9]): >
([0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}) >
([0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}): ";

 tried to match the test_patterns and test_log result failed.
 Does any one know what is wrong with the RE pattern I defined for the
 test_patterns variable?

 Thanks
Sam

 
 
 

why this RE failed?

Post by Daniel Hartmeie » Sat, 11 May 2002 02:44:27



>  const char *test_patterns = "(block|pass) (out|in) on ([a-z]+[0-9]): >
> ([0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}) >

             ^^
This doesn't even compile...

Daniel

 
 
 

why this RE failed?

Post by Sam Wu » Sat, 11 May 2002 15:55:55


How do you test it? I just follow the documentation of the regular
expressoin syntax. May be regex.h in oopenbsd doesn't support this syntax?

Thanks
Sam



> >  const char *test_patterns = "(block|pass) (out|in) on ([a-z]+[0-9]): >
> > ([0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}) >
>              ^^
> This doesn't even compile...

> Daniel

 
 
 

why this RE failed?

Post by Stelios Sfakianak » Sat, 11 May 2002 23:16:17






>Following is a sample C code:

> #include <regex.h>

Ok, although I haven't used REs inside C programs, here are my
comments:

Quote:>const char *test_log = "block out on tun0: 208.167.249.251.1247 >
>216.136.175.99.80: ";

> const char *test_patterns = "(block|pass) (out|in) on ([a-z]+[0-9]): >

The last '>' character does not match

Quote:>([0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}) >

You should put another backslash for every one you have in order to
protect them against the compiler, i.e. you should have
"([0-9]{1,3}\\.[0-9]{1,3}..."
Also in the test_log string you have a 4-digit port number but in the
RE you have "[0-9]{1,3}".

HTH
Stelios

Quote:>([0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}): ";

> tried to match the test_patterns and test_log result failed.
> Does any one know what is wrong with the RE pattern I defined for the
> test_patterns variable?

> Thanks
>Sam

 
 
 

1. why is mmap() failing?

My mmap() call fails under Ultrix with errno 22, invalid argument. Here
is some relevant piece of code:

  FILE *msg;
  char *file="some-file";
  struct stat_buf;
  caddr_t pa, p;

  msg = fopen (file, "r");
  stat (file, &stat_buf);
  if ((p = pa = (caddr_t) mmap (0, stat_buf.st_size, PROT_READ, MAP_SHARED,
                                fileno (msg), 0)) ==
      (caddr_t) -1)
    perror (""),
    exit (1);

Same code works under AIX, HPUX, IRIX, SUNOS, Solaris.

Can somebody tell me what is going on?

thanks in advance.

tasos

2. QUOTA available for v1.1.49 yet?

3. Reformatting man pages. Why does it fail?

4. Linux as a "dial-up" inet-provider...

5. Q: why does kermit fail from X?

6. No boot

7. Why does automounter fail once then never work again?

8. free business

9. Why does code fail to find *exact* amouut of RAM??

10. Why does Linux fail in a malloc of > 50 MB?

11. Why does ioctl fail on my enet card?

12. Why is rsh failing with this socket error?

13. Why is sendmail failing to deliver incoming mail???