On Sat, 2011-09-24 at 09:31 +0200, Jakub Jankowski wrote:
On 2011-09-24, Luis Pugoy wrote:
rewrite r_rewrite_subst { subst("a*", "?", value("MESSAGE") type("pcre") flags("utf8" "global")); };
I thought that it would replace 0 or more occurrences of 'a' with a question mark. However, when the input is 'a', the output becomes 'a?'. It just appends a question mark at the end. 'aa' also becomes 'aa?'. What is weirder still is that even if the input does not contain 'a', the question mark is still appended. So '1' becomes '1?'.
Well, does "1" match /a*/ ? :) It doesn't make any difference if that's /a*/, /b*/ or /.*/ - this kind of regexp matches everything, even an empty string.
Exactly. 'a*' matches the empty string and since you are performing global replacements, that would be triggered for each character. -- Bazsi