Board index » cppbuilder » Regular Expressions and BCB5

Regular Expressions and BCB5


2004-01-27 01:41:12 AM
cppbuilder94
am trying to learn how to use Regular Expressions in BCB5, I have read the
online help relating to this. I typed in Perl and then read a heap of
un-helpful words that brought me no closer to understanding the hows and
whys then before I started.
All I can fathom is; the basic idea is that you first compile your
expression (pcre_compile()) and then 'run' the compiled expression against
your search space(pcre_match())
The only reason I think I know that is someone told me it but still I have
no idea what that means and online help has NOT helped me. When I try to
compile either of the following I receive an error stating I am using an
undefined function which makes me think I need an include, but I can not
find what include to put in.
I have NO IDEA how to use Regular Expressions in BCB5 could someone please
help me.
Thanks
Warren
 
 

Re:Regular Expressions and BCB5

Hello Warren
Yes, i used Regular Expressions in CBuilder. I've written (or copied
from Help, i dont know anymore ;-) a little match-Function, which does
the compiling of the Regular Expression, and the comparing for me.
-----------------------------------------------------------------------
int match(const char *string, char *pattern)
{
int status;
regex_t re;
/* if (regcomp(&re, pattern, REG_EXTENDED|REG_NOSUB) != 0) {
return(0); // report error
} */
if (regcomp(&re, pattern, NULL) != 0) {
return(0); /* report error */
}
status = regexec(&re, string, (size_t) 0, NULL, 0);
regfree(&re);
if (status != 0) {
return(0); /* report error */
}
return(1);
}
-------------------------------------------------------------------------
This works fine.
I include the following Library:
#include <pcreposix.h>
Yes, like the most things, its not as easy as in Perl. But what about
an derived Ansistring-Class with some Regular Expression
functionality? Just an Idea...
Mirjam
"Warren" < XXXX@XXXXX.COM >wrote in message news:<micRb.29605$oj2.13460@edtnps89>...
Quote
am trying to learn how to use Regular Expressions in BCB5, I have read the
online help relating to this. I typed in Perl and then read a heap of
un-helpful words that brought me no closer to understanding the hows and
whys then before I started.

All I can fathom is; the basic idea is that you first compile your
expression (pcre_compile()) and then 'run' the compiled expression against
your search space(pcre_match())

The only reason I think I know that is someone told me it but still I have
no idea what that means and online help has NOT helped me. When I try to
compile either of the following I receive an error stating I am using an
undefined function which makes me think I need an include, but I can not
find what include to put in.

I have NO IDEA how to use Regular Expressions in BCB5 could someone please
help me.

Thanks

Warren