Hi folks, I try ro rework a property block from by using the regular expression features in the replace dialog of Lazarus 2.0.4
The code looks like that:
The expession for the scanning process is:
(^\s+[A-Za-z0-9])|([A-Za-z0-9]+$)
which means:
- first pattern is from line start until the end if the identifier limited by space righthand side
- second pattern is the identifier separated by space space lefthand side to the line end
The expession for the replacement:
property $1 $2 read f$1 ;
Dispite of using the multiline switch (which scrambels the output a little bit more) or not I go the strange result:
property f read f f;Scanner: TStringList;
IMO it should be:
property fScanner: TStringList read fScanner;
Neither the colon nor the semicolon is part of the output deal and the placeholder $1 and $2 are also not in place.
What I'm doing wrong?
Remarks: A Test with the
regexpr unit and the code:
program TestReplace;
uses RegExpr;
var S,G1, G2, G3, R: String;
begin
S:= 'Ident: TType;';
G1:= ReplaceRegExpr('(^\w+)|(\w+)|(;$)',S,
'$1',true);
G2:= ReplaceRegExpr('(^\w+)|(\w+)|(;$)',S,
'$2',true);
G3:= ReplaceRegExpr('(^\w+)|(\w+)|(;$)',S,
'$3',true);
R:= ReplaceRegExpr('(^\w+)|(\w+)|(;$)',S,
'$1 $2 BLAH $1 $3',false);
writeln('SOURCE: "', S,'"');
writeln('GROUP1: "', G1,'"');
writeln('GROUP2: "', G2,'"');
writeln('GROUP3: "', G3,'"');
writeln('RESULT: "', R,'"');
end.
gives more strange results.
SOURCE: "Ident: TType;"
GROUP1: "Ident: "
GROUP2: ": TType"
GROUP3: ": ;"
RESULT: "property Ident read Ident : property TType read property read ;"
Best Regards Huck