 |
BorlandTalk.com Borland discussion newsgroups
|
| View previous topic :: View next topic |
| Author |
Message |
Warren Guest
|
Posted: Mon Jan 26, 2004 5:40 pm Post subject: Regular Expressions and BCB5 |
|
|
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
|
|
| Back to top |
|
 |
Mirjam Guest
|
Posted: Wed Feb 04, 2004 4:32 pm Post subject: 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" <warren (AT) REMOVEwyght (DOT) com> wrote
| 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
|
|
|
| Back to top |
|
 |
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
|