jmgrep

7 November 2005, Jean-Michel Fauth


jmgrep is a grep like utility with text replacement capabilities. It is available as Python script.

Parameters

Pattern to find: String or pattern for the regular expression to be searched
Filename pattern: Filenames, "*" and "?" are allowed, see fnmatch in the Python doc
Source dir: Directory of files to be examined
Replacement string: Substitution string
Destination dir: Directory where the modified files are saved. Source and destination dirs must be different.

Commands

F4:Clear log windows
F5: Find the pattern
F6: Find and replace the pattern. The modified files are saved in the destination dir.
F7: Remove empty lines. The modified files are saved in the destination dir.

A few things to know

More complexe searches/replaces

Eg multiple directories, subdirectories, multiple files pattern.

The jmgrep application is composed of two Python modules, jmgreptools.py and jmgrep.py.
jmgreptools.py is the search/replace engine. It contains all search and replace functions and it is a pure Python module. jmgrep.py is only a graphical user interface built around jmgreptools.py.

More sophisicated search/replace can be easily achieved through a pure Python script using the functions of the jmgreptools.py module.

There is no plan to include these features in the user interface.

Case sensitivity

All searches are case sensitive, standard and regular expression methods. (Expert note: the pattern of a regular expression is compiled without the IGNORECASE flag).

I deliberately do not include this feature in my search engine. Some Python modules (string, re) do not understand accented characters very well.

Note, there is always the possibilitiy to use a regular expression pattern, that makes the searches insensitive to the character case.

Development

w2k (sp4), Python 2.4.2, wxPython 2.6.1