i have text like (with new line etc.), eg.:
[my_tag]foo[/my_tag]
bar baz [my_tag]bar
foo[/my_tag]
foo [my_tag]bar baz
foo[/my_tag]
i want totally remove all [my_tag][/my_tag] content, eg.:
[my_tag][/my_tag]
bar baz [my_tag][/my_tag]
foo [my_tag][/my_tag]
my code not work (it seems not match newline):
var
aPerlRegEx : TPerlRegEx;
aContent : string;
begin
aContent := '';
aContent := aContent + '[my_tag]foo[/my_tag]' + #13#10;
aContent := aContent + 'bar baz [my_tag]bar ' + #13#10;
aContent := aContent + 'foo[/my_tag] ' + #13#10;
aContent := aContent + 'foo [my_tag]bar baz' + #13#10;
aContent := aContent + 'foo[/my_tag] ' + #13#10;
aPerlRegEx := TPerlRegEx.Create;
try
with aPerlRegEx do begin
Options := [preCaseLess, preMultiLine];
RegEx := '\[my_tag\].*?\[\/my_tag\]';
Subject := aContent;
Replacement := '';
end;
if aPerlRegEx.Match then
aPerlRegEx.ReplaceAll;
writeln(aPerlRegEx.Subject);
finally
FreeAndNil(aPerlRegEx);
end;
preSingleLineflag. And removepreMultiLine