diff --git a/tren.rst b/tren.rst index cb6f8f8..5b021a9 100644 --- a/tren.rst +++ b/tren.rst @@ -1082,13 +1082,13 @@ ``-r`` option *literally*. However, it is sometimes handy to be able to write a regular expression to specify what you want replaced. If you specify the ``-x`` option, **tren** will treat your old string as -a Python style regex, compile it (or try to anyway!) and use it to +a regular expresion, compile it (or try to anyway!) and use it to select which strings to replace. This makes it much easier to rename files that have repeated characters or patterns, and groups of files that have similar, but not idential strings in their names you'd like to replace. -Say you have a set of files that are similar, but not idential in +Say you have a set of files that are similar, but not identical in name, and you want to rename them all:: sbbs-1.txt @@ -1117,7 +1117,12 @@ enabled you can include *both* regular expressions and literal text in your "old string" specification. The only requirement is that the string taken as a whole must be a valid Python regular expression. If -it is not, **tren** will display an error message to that effect. +it is not, **tren** will display an error message to that effect. + +For more detail on the Python regular expression syntax, see: + + http://docs.python.org/library/re.html + Because Python regular expressions can make use of the ``=`` symbol, you need a way to distinguish between an ``=`` used in a regular @@ -1125,14 +1130,14 @@ operands for the ``-r`` option. Where this symbol needs to appear in a regular expression, it has to be escaped like this: ``\=``. -Regular expression processing is unaffected by the ``-g / -1`` (global -rename) and ``-c / -C`` (ignore case) options. That's because there -are regular expression mechanisms for achieving the same thing. More -importantly, if you've selected regular expression matching, it's -probably because you want very fine grained control of the renaming -defined by the regex. In short, regular expression matching always -takes place on the *original characters* of the target portion of the -name and does replacement as called for in the regex itself. +As with literal string renaming, regular expression renaming requests +honor both the case-sensitivity options (``-C`` and ``-c``) as well +as the instance option, ``-i``. So, for example:: + + tren.py -x -ci -1 -r Bb+=X sbbsbbbsbbbbsbbbbbs + +You'll rename the file to ``sbbsbbbsbbbbsXs`` + Changing The Renaming Separator & Escape Characters @@ -1711,7 +1716,7 @@ :: - $Id: tren.rst,v 1.156 2010/03/29 03:00:47 tundra Exp $ + $Id: tren.rst,v 1.157 2010/03/29 15:49:55 tundra Exp $ You can find the latest version of this program at: