![]() System : Linux absol.cf 5.4.0-198-generic #218-Ubuntu SMP Fri Sep 27 20:18:53 UTC 2024 x86_64 User : www-data ( 33) PHP Version : 7.4.33 Disable Function : pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wifcontinued,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_get_handler,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,pcntl_async_signals,pcntl_unshare, Directory : /usr/share/emscripten/tests/core/ |
Upload File : |
// This is from// http://pic.dhe.ibm.com/infocenter/iseries/v7r1m0/index.jsp?topic=%2Frtref%2Fregexec.htm #include <regex.h> #include <stdio.h> #include <stdlib.h> int main(void) { regex_t preg; const char *string = "a very simple simple simple string"; const char *pattern = "\\(sim[a-z]le\\) \\1"; int rc; size_t nmatch = 2; regmatch_t pmatch[2]; if (0 != (rc = regcomp(&preg, pattern, 0))) { printf("regcomp() failed, returning nonzero (%d)\n", rc); exit(EXIT_FAILURE); } if (0 != (rc = regexec(&preg, string, nmatch, pmatch, 0))) { printf("Failed to match '%s' with '%s',returning %d.\n", string, pattern, rc); } else { printf( "With the whole expression, " "a matched substring \"%.*s\" is found at position %d to %d.\n", pmatch[0].rm_eo - pmatch[0].rm_so, &string[pmatch[0].rm_so], pmatch[0].rm_so, pmatch[0].rm_eo - 1); printf( "With the sub-expression, " "a matched substring \"%.*s\" is found at position %d to %d.\n", pmatch[1].rm_eo - pmatch[1].rm_so, &string[pmatch[1].rm_so], pmatch[1].rm_so, pmatch[1].rm_eo - 1); } regfree(&preg); return 0; }