Scroll Down to See All
abortabsacosasctimeasctime_rasinassertatanatan2atexitatofatoiatolbsearchbtowccalloccatclosecatgetscatopenceilclearerrclockcoscoshctimectime_rdifftimediverferfcexitexpfabsfclosefdopenfeofferrorfflushfgetcfgetposfgetsfgetwcfgetwsfopenfprintffputcfputwsfreadfreefreopenfrexpfscanffseekfsetposftellfwidefwprintffwritefwscanfgetcgetchargetenvgetwcgetwchargmtimegmtime_rhypotisalnumisalphaisasciiisblankiscntrlisdigitisgraphislowerisprintispunctisspaceisupperiswalnumiswalphaiswblankiswcntrliswctypeiswdigitiswgraphiswloweriswprintiswpunctiswspaceiswupperiswxdigitisxdigitj0j1jnlabsldexpldivlocaleconvlocaltimelocaltime_rloglog10longjmpmallocmblenmbrlenmbrtowcmbsinitmbsrtowcsmbstowcsmbtowcmemchrmemcmpmemcpymemmovememsetmktimemodfnextafternextafterlnexttowardnexttowardlnl_langinfoperrorpowprintfputcputcharputenvputsputwcputwcharqsortquantexpd32quantexpd64quantexpd128quantized32quantized64quantized128samequantumd32raiserandrand_rreallocregcompregerrorregfreeremoverenamerewindscanfsetbufsetjmpsetlocalesetvbufsignalsinsinhsnprintfsprintfsqrtsrandsscanfstrcasecmpstrcatstrchrstrcmpstrcollstrcpystrcspnstrerrorstrfmonstrftimestrlenstrncasecmpstrncatstrncmpstrncpystrpbrkstrptimestrrchrstrspnstrstrstrtodstrtod32strtod64strtod128strtofstrtokstrtok_rstrtolstrtoldstrtoulstrxfrmswprintfswscanfsystemtantanhtimetime64tmpfiletmpnamtoasciitolowertouppertowctranstowlowertowupperungetcungetwcva_argva_copyva_endva_startvfprintfvfscanfvfwprintfvfwscanfvprintfvscanfvsprintfvsnprintfvsscanfvswprintfvswscanfvwprintfvwscanfwcrtombwcscatwcschrwcscmpwcscollwcscpywcscpywcsftimewcslenwcsncatwcsncmpwcsncpywcspbrkwcsptimewcsrchrwcsrtombswcsspnwcsstrwcstodwcstod32wcstod64wcstod128wcstofwcstokwcstolwcstoldwcstombswcstoulwcsxfrmwctobwctombwctranswctypewcwidthwmemchrwmemcmpwmemcpywmemmovewmemsetwprintfwscanfy0y1yn



Function Details : regexec

intregexec(const regex_t * preg,const char * string,size_t nmatch,regmatch_t * pmatch,int eflags) ;

Return Type : int

Integer type (typically 4 bytes, -2,147,483,648 to 2,147,483,647)
Read about return values of regexec function .

1st Parameter Type : const regex_t *

A pointer to a constant `regex_t` structure representing a compiled regular expression. The `const` qualifier ensures the structure cannot be modified through this pointer.

1st Parameter

Pointer to a compiled regular expression structure created by `regcomp`.

2nd Parameter Type : const char *

Pointer to read-only string

2nd Parameter

The null-terminated string to be matched against the compiled regular expression.

3rd Parameter Type : size_t

Platform-specific unsigned type for array indices and memory sizes.

3rd Parameter

The maximum number of match structures to populate in the `pmatch` array.

4th Parameter Type : regmatch_t *

A pointer to an array of `regmatch_t` structures, where each structure represents a match with fields for the starting and ending positions of the substring matched by a regular expression.

4th Parameter

Pointer to an array of `regmatch_t` structures where match positions are stored. Can be `NULL` if matches are not needed.

5th Parameter Type : int

Integer type (typically 4 bytes, -2,147,483,648 to 2,147,483,647)

5th Parameter

Flags modifying the behavior of the match, such as `REG_NOTBOL` or `REG_NOTEOL`.

Read more about parameters of regexec in parameters section
The regexecfunction in C language Matches a null-terminated string against the precompiled pattern buffer specified by regex_t.
The regexec function is used to match a null-terminated string against a precompiled regular expression. It can optionally provide information about the location of the match and any captured subexpressions.
The regexecfunction takes 5 parameters:
  • const regex_t * `preg`: Pointer to a compiled regular expression structure created by `regcomp`.
  • const char * `string`: The null-terminated string to be matched against the compiled regular expression.
  • size_t `nmatch`: The maximum number of match structures to populate in the `pmatch` array.
  • regmatch_t * `pmatch`: Pointer to an array of `regmatch_t` structures where match positions are stored. Can be `NULL` if matches are not needed.
  • int `eflags`: Flags modifying the behavior of the match, such as `REG_NOTBOL` or `REG_NOTEOL`.
Executes a regular expression match using the compiled regex structure `preg` against the input `string`. If `pmatch` is provided, it stores match positions up to `nmatch` elements. Returns `0` if the match is successful, `REG_NOMATCH` if no match is found, or another nonzero error code for other errors.
The regexec function return value :
  • Returns 0 for a successful match, REG_NOMATCH for no match, or other non-zero values for errors

Output

This example demonstrates basic usage of regexec to match a string against a compiled regular expression.