mjn
mjn

Reputation: 36654

GExperts grep expression for source lines with string literals (for translation)

How can I find all lines in Delphi source code using GExperts grep search which contain a string literal instead of a resource string, except those lines which are marked as 'do not translate'?

Example:

this line should match

  ShowMessage('Fatal error! Save all data and restart the application');

this line should not match

  FieldByName('End Date').Clear; // do not translate

(Asking specifically about GExpert as it has a limited grep implementation afaik)

Upvotes: 3

Views: 891

Answers (1)

Jeroen Wiert Pluimers
Jeroen Wiert Pluimers

Reputation: 24493

Regular Expressions cannot be negated in general.

Since you want to negate a portion of the search, this comes as close as I could get it within the RegEx boundaries that GExpers Grep Search understands:

\'.*\'.*[^n][^o][^t][^ ][^t][^r][^a][^n][^s][^l][^a][^t][^e]$

Edit: Forgot the end-of-line $ marker, as GExperts Grep Search cannot do without.

blokhead explains why you cannot negate in general.

This Visual Studio Quick Search uses the tilde for negation, but the GExperts Grep Search cannot.

The grep command-line search has the -v (reverse) option to negate a complete search (but not a partial search).

A perfect manual negation gets complicated very rapidly.

--jeroen

Upvotes: 2

Related Questions