Article View: pl.comp.os.linux.programowanie
Article #337Re: obsluga regexpow
From: Łukasz Kowalczyk
Date: Sun, 12 Sep 1999 23:18
Date: Sun, 12 Sep 1999 23:18
34 lines
1743 bytes
1743 bytes
[ japhy ]
> Szukam jakichkolwiek wskazowek jak obslugiwac regexpy.
man regcomp
man regexec
man regfree
Ewentualnie ``pinfo libc'', rozdział "Pattern matching".
> Przegladalem regex.h i regexp.h ale mnie to nic nie mowi -
> - mnie chodzi konkretnie o funkcje
> int is_regexp(char *pattern, char *string)
> zwracajaca zero jak pasuje, kod bledu jak nie (co konkretnie nie pasuje)
Z pomocą tych dwóch funkcji bez problemu napiszesz sobie coś takiego:
#include <stdio.h>
#include <regex.h>
int regmatch(char *pattern, char *string, int cflags, int eflags) {
regex_t rcomp;
int retval;
if (regcomp(&rcomp, pattern, cflags | REG_NOSUB) != 0) return -1;
/* REG_NOSUB dla uproszczenia */
retval = regexec(&rcomp, string, 0, NULL, eflags);
regfree(&rcomp);
return retval;
}
--
Łukasz Kowalczyk
lukow<at>tempac.fuw.edu.pl http://tempac.fuw.edu.pl/~lukow/
Technical Details
Message-ID:
<slrn7tobhj.tdt.smithy@hoohoo.org>Path:
mbox-mo1.pugleaf.net!news-archive.icm.edu.pl!pingwin.icm.edu.pl!mat.uni.torun.pl!news.nask.pl!news.icm.edu.pl!smithyReferences:
<slrn7tnt0f.efu.pankrac@jessie.lonet.gdynia.pl>Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!news-archive.icm.edu.pl!pingwin.icm.edu.pl!mat.uni.torun.pl!news.nask.pl!news.icm.edu.pl!smithy From: Łukasz Kowalczyk <smithy@promail.pl> Newsgroups: pl.comp.os.linux.programowanie Subject: Re: obsluga regexpow Date: 12 Sep 1999 23:18:35 GMT Organization: Jazz Police Lines: 34 Message-ID: <slrn7tobhj.tdt.smithy@hoohoo.org> References: <slrn7tnt0f.efu.pankrac@jessie.lonet.gdynia.pl> NNTP-Posting-Host: pd99.warszawa.ppp.tpnet.pl Mime-Version: 1.0 X-Trace: sunsite.icm.edu.pl 937178315 22848 212.160.55.99 (12 Sep 1999 23:18:35 GMT) X-Complaints-To: abuse@news.icm.edu.pl NNTP-Posting-Date: 12 Sep 1999 23:18:35 GMT User-Agent: slrn/0.9.5.7 (UNIX) Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit