Regular expressions for missing parameter modifiers

[(;]\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

Advertisements

Leave a Reply

Please log in using one of these methods to post your comment:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s