delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1997/12/22/03:18:48

Date: Mon, 22 Dec 1997 10:16:11 +0200 (IST)
From: Eli Zaretskii <eliz AT is DOT elta DOT co DOT il>
To: djgpp AT delorie DOT com
Subject: Re: reg*()
In-Reply-To: <bWLoegW7sFse-pn2-1nBVdkZv3UgF@portC26.Generation.NET>
Message-ID: <Pine.SUN.3.91.971222101456.10387G-100000@is>
MIME-Version: 1.0

On 21 Dec 1997 Gili wrote:

> 	I hope I'm not the first to say this but .. reg*() functions confused
> the heck out of me. The online help doesn't help one bit.. What do 
> these functions do? What are they used for?

These functions are for testing whether a string matches a given
regular expression.  If you don't know anything about regular
expressions, they might indeed confuse you, but the library reference
cannot be a substitute for what takes several chapters in a book to
explain.

In short, regular expressions is a generalization of a string.  When
you need to see whether one string includes "foobar" as its substring,
you might say something like this:

	  int matches = strstr (my_string, "foobar") != NULL;

But what about the cases where instead of a fixed string "foobar" you
are interested to know whether `my_string' has substrings which begin
with an `f' or `F', end with an `r' or `R' and you don't care about
what's in between?  That's where the regular expressions come in
handy.  A regular expression such as "[fF].*[rR]" is the translation
of the above vague substring spec.

With the above in mind, you should be able to reread the docs and
understand it better, I hope.  So to say that ``online help doesn't
help one bit'' is a little extreme, IMHO.

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019