Hi all,

I want to add some regular expression support to software that I've written, which is entirely in C. From browsing the web, my sense is that PCRE is the best library for my purposes. However, before I devote too much time to it, I have some questions about it, which I'm hoping others can help me answer:

(1) Is there a function in the library that can perform pattern matching substitutions? I'm looking for a function sort of like this:

int matchandsub(pattern1,string1,pattern2,string2);

For example, suppose I gave this function pattern1="a.c", string1="abc", and pattern2="j.k"; string2 is only for output. I want the function to see that yes, string1 is a correct match for pattern1 and that the letter b is the substituted letter. Then, it puts 'b' into pattern2, returning it in string2 as "jbk". In general, pattern1 and pattern2 would have to have the same expression forms (or, more precisely, pattern2 would need to have a subset of the expressions used in pattern1).

(2) Does PCRE, or any regular expression library, support pattern permutations? For example, it's standard that the expression "abc|def" matches to either "abc" or "def". However, I want to write the expression "abc&def" and to have this match to either "abcdef" or to "defabc".

Thank you!
-Steve