Jason Meade wrote:
Is there a standard for regular expressions somewhere?
"a standard"? No. "are standards"? Yes. Many. Naturally, that is the problem.
It seems like most implements (from grep through tcl, perl, and beyond) seem to agree on simple stuff like ^[a-c]?002*[^b]+$ etc... (not all understand ? and + I've noticed....) but very few seem to share an affinity for \w or \< ... \> etcetera. I don't use regular expressions (outside of grep) everyday, but when I do use them, it's usually for some serious pattern matching, with variable capture (via $1, or \#1 etc). I'm starting to incorporate search-forward and search-backwards into my filebuffer lib. For that kind of work, even strchr will work (sorta. binary data is a problem). However, eventually I'll want to be able to regex my buffers, and once I add the guile hooks, it would be nice to share the same regex syntax with everyone else. After all, the last thing you want is to load a module, only to find that it's not syntax compatible with the rest of the language!
The most comprehensible and still useful thing would be to provide a "regcomp" funtion that had a usable implementation of the REG_BASIC flag and, perhaps, added such tweaks as REG_PERL et al. The reason I said, "usable implementation" is because in my implementation of regexec(3C), REG_BASIC is not defined so there is no way to tell the regex compiler that I want a basic re. SO, into the guile.h family of headers, add: #ifndef REG_BASIC # define GUILE_REG_BASIC 0x10000 #else # define GUILE_REG_BASIC REG_BASIC #endif then overload "make-regexp" and "regexp-exec" to cope with this and "I'd-rather-use-Perl-syntax" flags. Or even a "I-want-fnmatch- style-globbing" match flag. It brings all the pattern matching stuff together making it findable (very important in a huge interface) and relatively easy to use (i.e. remember). :) That's my nickel. Cheers - Bruce P.S. one thing missing from the ice-9 regex functions seems to be a way to pass such flags through to the implementing libguile functions. Perhaps I just missed how to do it? (define (string-match pattern str . args) (let ((rx (make-regexp pattern)) (start (if (pair? args) (car args) 0))) (regexp-exec rx str start))) _______________________________________________ Guile-devel mailing list Guile-devel@gnu.org http://lists.gnu.org/mailman/listinfo/guile-devel