codepad
[
create a new paste
]
login
|
about
Language:
C
C++
D
Haskell
Lua
OCaml
PHP
Perl
Plain Text
Python
Ruby
Scheme
Tcl
#include <stdio.h> #include <regex.h> int regex_match (char *pattern, const char *string) { int status; regex_t re; status = regcomp (&re, pattern, REG_EXTENDED|REG_NOSUB); if (status != 0) { return (0); } status = regexec (&re, string, (size_t) 0, NULL, 0); if (status != 0) { regfree (&re); return (0); } regfree (&re); return (1); } int main (void) { char *string = "Ciao amore mio"; char *re = "iao"; if (regex_match (re, string)) { printf ("Il modello \"%s\" trova corrispondenza ", re); printf ("nella stringa \"%s\"\n", string); } else { printf ("Il modello \"%s\" ", re); printf ("NON trova corrispondenza "); printf ("nella stringa \"%s\"\n", string); } return 0; }
Private
[
?
]
Run code
Submit