reFind.exe, the Search and Replace Utility Using Perl RegEx Expressions Go Up to Command-Line Utilities Index
reFind is a command-line utility for search and replacement of Perl RegEx text patterns in a text file.
For instructions on using reFind to migrate:
Existing AnyDAC applications to FireDAC, see Migrating AnyDAC Applications to FireDAC. Existing BDE applications to FireDAC, see Migrating BDE Applications to FireDAC. Existing dbExpress applications to FireDAC, see Migrating dbExpress Applications to FireDAC. Contents 1 Command-Line Help 2 Patterns Format 3 Rules Format 3.1 Seach and Replace Rule 3.2 Remove Unit Rule 3.3 Remove Property Rule 3.4 Migrate Rule 4 Examples 5 See Also Command-Line Help RegEx (PCRE) search and replace utility, v 2.5 Copyright (c) 2013 Embarcadero Technologies, Inc.
<filemasks> Specifies the file masks or file names to process.
/? Displays help. /S Search this directory with all subdirectories. /Y Modify also read-only files. /B:0 if .bak file exists no replace will be performed (default). /B:1 if .bak file exists, it is overwritten. /B:2 No .bak file is created. /Q Quiet operation. No output to console.
/I Ignore case. /W Whole words. /L Multi line search. /P Perl RegEx search pattern. /R Perl RegEx replacement pattern. /X Specifies rule file with multiple Perl RegEx search and replace patterns or rules.
The rule formats: #unuse <unit> - remove unit from the PAS uses clause #remove <property> - remove property from PAS and DFM #migrate [<class> :] <old> -> <new> [, <unit>] - replace old with new identifier, optionally add unit to uses clause, optionally restrict migration to the specified class
Each file line has format: <searchpattern> -> <replacepattern> Patterns Format reFind uses Perl compatible regular expressions (PCRE) for search and replacement patterns.
Seach and Replace Rule <search pattern> -> <replace pattern> <Search pattern> is a PCRE search pattern. <Replace pattern> is a PCRE replace pattern.
Remove Unit Rule #unuse <unit name> Removes the specified <unit name> from the interface and the implementation section of the "uses" clauses of the PAS files.
Remove Property Rule #remove <property name> Removes the specified <property name> from PAS and DFM files. From a PAS file, it will remove any construction like <prop> := <value>;.
Migrate Rule #migrate [<class> :] <old name> -> <new name> [, <unit>] Replaces all <old name> identifiers with a <new name> in PAS and DFM files. If the <class> is specified, then the rule will be applied only to the objects of the specified class:
DFM - only to base objects, not to inherited ones; PAS - only to <obj>.<old name> constructions, not to the "with" clauses content. If the <unit> is specified, then it will be added to the "uses" clause of the PAS unit part, where the <old name> is found. The <unit> may be a comma-separated list of the units.
Examples Replace all "TQuery" with "TFDQuery" in pas files : refind *.pas /I /W /P:TQuery /R:TFDQuery Replace all "TxxxQuery" with "TFDQuery" in pas and dfm files : refind *.pas *.dfm /I /W "/P:T[A-Za-z]+Query" /R:TFDQuery Replace all "TxxxQuery" with "TQueryxxx" in pas and dfm files : refind *.pas *.dfm /I /W "/P:T([A-Za-z]+)Query" /R:TQuery\1 Remove all "Origin = xxxx" from DFM files : refind *.dfm /L "/P:\n +Origin =.+$" "/R:" Migrate application from BDE to FireDAC: reFind *.pas *.dfm /X:FireDAC_Migrate_BDE.txt See Also Regular Expressions GREP.EXE, the text search utility Search Menu Migrating AnyDAC Applications to FireDAC Migrating BDE Applications to FireDAC Migrating dbExpress Applications to FireDAC Category: XE5
The higher the degree, the greater the respect given to the humblest!