REGEX Confusion 
Author Message
 REGEX Confusion

Trying to figure out a regular expression on an AIX system.  I've been reading
the SED & AWK book from O'Reilly and I'm trying to understand the use of {n,m}
(match a range of occurrences of the preceding single character).

echo "/dir1/dir2/dir3/file"|awk '{if ( $0 ~ /^\/.{1,19}$/ ) print "match" ; else
print "no match"}'

yields "match".  Any value <19 yields "no match", understandable since the
incoming string is 20 characters.  Any value >19 but <255 still yields "match".

Why does a value >255 yield "no match"?  Is there a limit?  I cannot find any
reference to a limit when using {n,m} from AWK.

Any thoughts appreciated.



Sun, 10 Aug 2003 03:15:03 GMT  
 REGEX Confusion

Quote:

> Trying to figure out a regular expression on an AIX system. I've
> been reading the SED & AWK book from O'Reilly and I'm trying to
> understand the use of {n,m} (match a range of occurrences of the
> preceding single character).

> [snip]

> yields "match". Any value <19 yields "no match", understandable
> since the incoming string is 20 characters. Any value >19 but
> <255 still yields "match".

> Why does a value >255 yield "no match"? Is there a limit?

Yes. The limit is defined by RE_DUP_MAX in regex.h.

Quote:
> I cannot find any reference to a limit when using {n,m} from AWK.

From man regex(3) (e.g., <http://www.osxfaq.com/man/3/regex.html>):

    RE_DUP_MAX, the limit on repetition counts in bounded repetitions,
    is 255.

Try 'man 3 regex' on your AIX system.

--
Jim Monty

Tempe, Arizona USA



Sun, 10 Aug 2003 04:49:50 GMT  
 REGEX Confusion
Thanks for the reply.  I also found a reference in the SED & AWK book but
way past the section that first describes what I was doing.  The upper limit
is 255.


Quote:

> > Trying to figure out a regular expression on an AIX system. I've
> > been reading the SED & AWK book from O'Reilly and I'm trying to
> > understand the use of {n,m} (match a range of occurrences of the
> > preceding single character).

> > [snip]

> > yields "match". Any value <19 yields "no match", understandable
> > since the incoming string is 20 characters. Any value >19 but
> > <255 still yields "match".

> > Why does a value >255 yield "no match"? Is there a limit?

> Yes. The limit is defined by RE_DUP_MAX in regex.h.

> > I cannot find any reference to a limit when using {n,m} from AWK.

> From man regex(3) (e.g., <http://www.osxfaq.com/man/3/regex.html>):

>     RE_DUP_MAX, the limit on repetition counts in bounded repetitions,
>     is 255.

> Try 'man 3 regex' on your AIX system.

> --
> Jim Monty

> Tempe, Arizona USA



Sun, 10 Aug 2003 06:13:55 GMT  
 
 [ 3 post ] 

 Relevant Pages 

1. grep regex to ruby regex...

2. Regex++ or other Regex lib for Fortran?

3. Python regex / libc regex interactions

4. Confusion over TPROT

5. Newbie 'Absolute Expression' Confusion

6. If statement confusion

7. confusion with @ (atop) in J

8. The old quoting confusion problem

9. Collection inheritance confusion...

10. Referencing parent windows-more confusion.

11. Report confusion

12. Embed confusion - Please help

 

 
Powered by phpBB® Forum Software