master slider blank master slider blank

Search and Replace

Search and Replace

Is the most common operation that computers automate

image-icon

Searching and Replacing

Across hundreds, thousands or even millions of documents just cannot be done by a human. The time, and the errors introduced and replacements missed make it essential to find a set of tools to automate this whole process.

image-icon

Commonly an 'exact search' is required

whereby the text is found exactly as entered. However, to search for special characters such as carriage returns, line feeds, tabs etc, special 'escape codes' must be allowed such as \r, \n, \t, and these are interpreted specially. A backslash is entered as \\.

Even searching on its own, has spawned the necessity and creation of regular expressions. These are 'mini-programs' that look through text for a 'pattern' they match. Common search/replace examples are perl regular expressions and EasyPattern regular expressions.

image-icon

Very often the found text has to be replaced in a different arrangement

for example, replacing, re-arranging or substituting other text. A very common example is reformatting of dates from US to EU formats - mm/dd/yyyy to dd-mm-yyyy. To do this, part of the found text has to be 'captured' and then substituted into the replacement string. Usually the fragments of captured text are stored in 'macros' or 'variables' named $1, $2, $3 etc, with $0 representing the entire match.

Search and Replace

Tools