Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

basic, basic regex help, do i need alloc and pointer?

2 views
Skip to first unread message

Keith Kaple

unread,
Dec 29, 1998, 3:00:00 AM12/29/98
to
I'm trying to use regex.h to do a basic pattern match in c (like I've
done in PERL for years).

Do I really have to mess with memory allocation and pointers??

Anyone have a quick example of taking two strings and saying "is the
first in the second" ???

I don't care where, when or how many times, just, is the *^%$% string in
there.

Thanks


--
Keith Kaple x25759 -----------------------
| New distribution, $40. Linux compatible
| sound card, $89. Three button mouse, $18.
| Nuking windows partitions....priceless.

Luis Grave

unread,
Dec 30, 1998, 3:00:00 AM12/30/98
to

#include <stdio.h>
#include <string.h>

int is_the_first_in_the_second(const char *first, const char *second)
{
return strstr(second, first) != 0;
}

int main(void)
{
const char *clcFAQ = "http://www.eskimo.com/~scs/C-faq/top.html";
const char *FAQSalreadyread = "";

if(is_the_first_in_the_second(clcFAQ, FAQSalreadyread))
printf("ok\n");
else
printf("oops\n");
return 0;
}


--
-----------------------------------------------------------
Luis Grave mailto:lgr...@ccg.uc.pt

Dept. Teletrabalho, Visualisacao and Tecnologias Multimedia

Centro de Computacao Grafica http://www.ccg.uc.pt
-----------------------------------------------------------

0 new messages