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.
- Existing dbGo applications to FireDAC, see Migrating dbGo Applications to FireDac.
Contents
Command-Line Help
RegEx (PCRE) search and replace utility, v 2.5 Copyright (c) 2013 Embarcadero Technologies, Inc. Usage: reFind <filemasks> [/S] [/Y] [/B:0|1|2] [/Q] [/I] [/W] [/L] [/P:<searchpattern>] [/R:<replacepattern>] [/X:<rule filename> <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. /C Leave the old target code as a comment instead of deleting it. /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.
For more details, please visit:
- English: http://perldoc.perl.org/perlre.html#Regular-Expressions
- Russian: http://citforum.ru/internet/perl/regexp
Rules Format
The rule file consists of several lines, each of them representing a single rule. The rule file may be specified using the /X:<file name> command line parameter.
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