[GRASS5] regex routines

David D Gray ddgray at armadce.demon.co.uk
Wed Apr 18 14:42:48 EDT 2001


Glynn Clements wrote:
> 
> David D Gray wrote:
> 
> > One of the shortfalls in writing parsing routines I've found recently is
> > that there is no native regex handling stuff in GRASS. (is there?).
> 
> Do the regexps need to be constructed at run-time? If not, I would
> have thought that it would be better to write the parser using (f)lex.
> 

Mostly flex is used now where whole files are being scanned for input,
but there are instances where it is required to search for patterns in
an isolated string, and in those instances lex is cumbersome or just not
practical. For example, you might want to define a function G_gsub:

int G_gsub(char *pattern, char *replacement, char *str, int flags)

that is like the AWK function and replaces a matching pattern with a
replacement string. This would have to call the regex routines.

I find it is often useful to develop code in perl scripts and then when
that is working port to C, or if it's necessary to take code and move it
from modules to library routines. Most of the functionality is easy to
port, but basic regex functioning is the most difficult.

David

---------------------------------------- 
If you want to unsubscribe from GRASS Development Team mailing list write to:
minordomo at geog.uni-hannover.de with
subject 'unsubscribe grass5'



More information about the grass-dev mailing list