C + Regulaere Ausdruecke
-
Hi,
ich versuche gerade verzweifelt herauszubekommen, ob man unter C mittels der GNU regex library (regex.h) suchen und ersetzen kann.
Pseudocode:char *string = "foo"; char *regex = "s/foo/bar/" regreplace(string, regex);
Dann soll string = "bar" sein.
Ist sowas mit C moeglich, oder funktioniert das nur mit modernen
Sprachen?Danke!
-
nichts ist unmöglich und alles was mit script sprachen möglich ist geht auch in c nur mit höherem aufwand.
-
ach hab deine frage nicht beantwortet
GNU regex library (regex.h)
kanns nicht und pcre kanns auch nicht mußt dir selbst was basteln.
lg lolo
-
Vielleicht ist das was für dich: http://www.pcre.org/
-
PCRE NATIVE API
#include <pcre.h>
pcre *pcre_compile(const char *pattern, int options,
const char **errptr, int *erroffset,
const unsigned char *tableptr);pcre *pcre_compile2(const char *pattern, int options,
int *errorcodeptr,
const char **errptr, int *erroffset,
const unsigned char *tableptr);pcre_extra *pcre_study(const pcre *code, int options,
const char **errptr);int pcre_exec(const pcre *code, const pcre_extra *extra,
const char *subject, int length, int startoffset,
int options, int *ovector, int ovecsize);int pcre_dfa_exec(const pcre *code, const pcre_extra *extra,
const char *subject, int length, int startoffset,
int options, int *ovector, int ovecsize,
int *workspace, int wscount);int pcre_copy_named_substring(const pcre *code,
const char *subject, int *ovector,
int stringcount, const char *stringname,
char *buffer, int buffersize);int pcre_copy_substring(const char *subject, int *ovector,
int stringcount, int stringnumber, char *buffer,
int buffersize);int pcre_get_named_substring(const pcre *code,
const char *subject, int *ovector,
int stringcount, const char *stringname,
const char **stringptr);int pcre_get_stringnumber(const pcre *code,
const char *name);int pcre_get_stringtable_entries(const pcre *code,
const char *name, char **first, char **last);int pcre_get_substring(const char *subject, int *ovector,
int stringcount, int stringnumber,
const char **stringptr);int pcre_get_substring_list(const char *subject,
int *ovector, int stringcount, const char ***listptr);void pcre_free_substring(const char *stringptr);
void pcre_free_substring_list(const char **stringptr);
const unsigned char *pcre_maketables(void);
int pcre_fullinfo(const pcre *code, const pcre_extra *extra,
int what, void *where);int pcre_info(const pcre *code, int *optptr, int *firstcharptr);
int pcre_refcount(pcre *code, int adjust);
int pcre_config(int what, void *where);
char *pcre_version(void);
void *(*pcre_malloc)(size_t);
void (*pcre_free)(void *);
void *(*pcre_stack_malloc)(size_t);
void (*pcre_stack_free)(void *);
int (*pcre_callout)(pcre_callout_block *);