! \brief Match pattern against string and, if match succeeds, and replace string * with replacement substituting tokens \\d with matched substrings. */
| 105 | * with replacement substituting tokens \\d with matched substrings. |
| 106 | */ |
| 107 | int reg_replace(char *pattern, char *replacement, char *string, str *result) |
| 108 | { |
| 109 | regmatch_t pmatch[MAX_MATCH]; |
| 110 | |
| 111 | LM_DBG("pattern: '%s', replacement: '%s', string: '%s'\n", |
| 112 | pattern, replacement, string); |
| 113 | |
| 114 | if (reg_match(pattern, string, &(pmatch[0]))) { |
| 115 | return -1; |
| 116 | } |
| 117 | |
| 118 | return replace(&pmatch[0], string, replacement, result); |
| 119 | |
| 120 | } |
no test coverage detected