Date: Mon, 22 Dec 1997 10:16:11 +0200 (IST) From: Eli Zaretskii To: djgpp AT delorie DOT com Subject: Re: reg*() In-Reply-To: Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Precedence: bulk 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.