This page contains help on using latest version of nhreplace utility.
Search with regular expression
Replace text by a list of actions
Search for plain text
This command searches for plain text:
nhrplc.exe -spt:<plain text>|-set:<escape text> [-i] [-r] -t:<plain text>|-et:<escape text>|-f:<filename>[,<codepage>] [-cp:<codepage>[,<codepage>]] [-o:(q|s|d*)] [-notitle] <mask>...
Plain text to search can be specified
Replacement static text can be usual text (-t argument), text with escape characters (-et argument), or content of a text file (-f argument).
Search with regular expression
This command searches using regular expression:
nhrplc.exe -sre:<regexp> [-i] [-r] -t:<plain text>|-et:<escape text>|-ft:<formatted text>|-f:<filename>[,<codepage>] [-cp:<codepage>[,<codepage>]] [-o:(q|s|d*)] [-notitle] <mask>...
Regular expression for search specified with -sre argument.
Replacement static text can be:
- static text (-t argument),
- static text with escape characters (-et argument),
- formatted result of regular expression (-ft argument with $ flags),
- or content of a text file (-f argument).
Replace text by a list of actions
This command executes a number of searches at one nhreplace execution when used with -list argument:
nhrplc.exe -list:<replace file>[,<codepage>] [-r] [-cp:<codepage>[,<codepage>]] [-o:(q|s|d*)] [-notitle] <mask>...
List of action specified with -list argument pointing to an existing file with an action on each line:
-spt:<plain text>|-set:<escape text> [-i] -t:<plain text>|-et:<escape text>|-f:<filename>[,<codepage>] -sre:<regexp> [-i] -t:<plain text>|-et:<escape text>|-ft:<formatted text>|-f:<filename>[,<codepage>] ...
Convert file code page
This command converts file code page without affecting file content:
nhrplc.exe -cp:<кодовая страница>,<кодовая страница> [-notitle] [-o:q[uiet]|s[hort]|d[etailed]*] [-r] <маска>...
Replace text in stdin stream
These commands replace text coming in STDIN as files to process not specified.
Search for plain text:
nhrplc.exe -spt:<plain text>|-set:<escape text> [-i] -t:<plain text>|-et:<escape text>|-f:<filename>[,<codepage>] [-notitle]
Search using regular expression:
nhrplc.exe -sre:<regexp> [-i] -t:<plain text>|-et:<escape text>|-ft:<formatted text>|-f:<filename>[,<codepage>] [-notitle]
Replace by action list:
nhrplc.exe -list:<replace file>[,<codepage>] [-notitle]
Arguments
List of all supported arguments:
-spt, -searchplaintext
Search for plain text sample
-set, -searchescapetext
Search for plain text containing escaped characters:
- \” – double quots
- \r – Return Carriage
- \n – New Line
- \xHH – a character specified by its 8 bit code in hexadecimal form
- \uHHHH – a Unicode character specified by its 16 bit code in hexadecimal form
-sre, -searchregularexpression
Search using ECMAScript regular expression.
-list:<actions list file name>[,<codepage>]
Execute search and replace actions from a file containing one action per line. Each action can be specified with -spt, -set, or -sre arguments for search text and -t, -et, -ft, or -f for replacement text.
-spt, -set, -sre, -i, -t, -et, -ft, or -f cannot be used with -list.
-i, -ignorecase
Search ignoring case.
-t, -text
Replace with static plain text.
-e, -erase option
Erase found occurences. Used with -set/-sre.
-et, -escapetext
Replace with static plain text containing escaped characters \\””,\\r,\\n,\,\\xHH,\\uHHHH.
-ft, -formattedtext
Replace with formatted text (only when searching using regular expression, see -sre argument).
-fet, -formattedescapetext
Sets formatted text for searching with -sre.
Supports:
- capture groups as $1, $2 etc.
- escape characters:
\",\r,\n,\\,\xHH,\uHHHH
.
-f, -file
Replace with file content.
-nc, -nocopy option
Deletes text that does not match the regular expression. It can be used with -sre in the command line arguments or list file.
This option was intriduced in nhrt v2.13.
-o, -outputlevel
Output details level:
q quiet mode (nothing)
s short: only file name
d detailed: file names with replace count
-cp, -codepage
Code pages for reading and writing: auto*|ansi|oem|unicode|utf8|number (know more).
Return codes
Return code 0
The program processed 1 or more files and replaced 1 or more samples.
Return code 1
The program processed 1 or more files but no samples were found.
Return code 2
Error in command line arguments.
How to specify a code page
<code page> parameter may be specified as : auto|ansi|oem|unicode|utf8|<number> with default value auto.
ansi
8-bit charactes used by non-Unicode GUI applications. Depending on Windows language settings points to a real code page for example code page 1252 in Western languages.
oem
8-bit code page use by non-Unicode console applications. Depending on Windows language settings points to a real code page.
unicode
Uses 16 bits characters (UTF-16). May have BOM (Byte Order Mark). nhreplace detects can read Unicode file with BOM or without BOM but writes Unicode files always with BOM.
utf8
UTF-8 character encoding. nhreplace can read files in UTF-8 with BOM (Byte Order Mark) or without BOM while nhreplace writes UTF-8 files always with BOM.
<number>
Character encoding specified by code page number – 1251, 1252 etc.
Specifying character encoding by number allows to process files with any Windows supported code pages.
auto
When auto is specified for an existing file to read the actual character encoding will be determined by nhreplace automatically.
When auto is specified for an existing output file the program will keep current character encoding.
When auto is specified for non-existing output file the program will use Unicode.
See also
If you have another question on program features please see Frequently Asked Questions or post your question using comment form below.
If the program works not as expected please use nhrt support forum.