I have below code.
var
result := 'DECLARE''' + #13#10 + 'DECLARE''''';
result := TRegEx.Replace(result, '\A\s*DECLARE''\s*', 'abc', [roIgnoreCase]);
ShowMessage(result);
When I run it, I got:
This result is expected. However, when I change the replacement string to an empty string, like this:
result := 'DECLARE''' + #13#10 + 'DECLARE''''';
result := TRegEx.Replace(result, '\A\s*DECLARE''\s*', '', [roIgnoreCase]);
ShowMessage(result);
I got this result when run the program:
Why this happens? I only want to replace the first match, and that's why I use \A to anchor the regex at the beginning of the string.


\Aworks as(?m)^, it looks like a bug.