[(;]\s*(\w*)\s*:\s\w*[sS]tring\W

This expression locates most candidates for a missing const modifier for string types.

[(;]\s*(\w*)\s*:\s*([I]\w*|\w*[sS]tring)\W

Same as above, also includes type names beginning with the letter I (coding convention for interface types).

Examples

 // no match
procedure Test(const Arg: string);

 // match
procedure Test(Arg: WideString); 

// no match
procedure Test(const Arg: string; var Arg2: WideString); 

// match
procedure Test(const Arg: string; Arg2: AnsiString); 

Tested with GExperts Grep Search, which does not support multiline expressions.

Usage example with GExperts Grep Search

gexperts-grep


Discover more from Habarisoft Blog

Subscribe to get the latest posts sent to your email.

Leave a Reply

Your email address will not be published. Required fields are marked *