Regular Expressions in Renamer Plugin

The Renamer plugin uses more powerful regular expressions than Find and Internal Viewer in Altap Salamander. It extends REGEXP library, which is a great work of Henry Spencer. First see the Regular Expressions Syntax in Altap Salamander and then continue with description of Renamer extensions. These extensions were inspired in Perl.

Extended syntax

  • '*?' - non-greedy variant of '*' (match 0 or more times)
  • '+?' - non-greedy variant of '+' (match 1 or more times)
  • '??' - non-greedy variant of '?' (match 0 or 1 times)
  • '$' - at the end of the expression matches the end of a line (or before newline at the end)
  • '( )' - glues expressions in parentheses to one expression and captures a matched substring (see this example to understand how it works)
  • '(?: )' - works like "( )", but does not capture a matched substring

Note: "non-greedy" means that it matches the minimum number of times possible.

Zero-width assertions

You can use following zero-width assertions (it does not match any character, just test if some condition is true or not):

Assertion Meaning
\b Match a word boundary.
\B Match a non-(word boundary).
\A Match only at beginning of string.
\Z Match only at end of string, or before newline at the end.
\z Match only at end of string.
(?= ) Positive look-ahead assertion (for example, 'j(?=ohn)' matches 'j' in word 'john' but not in word 'june').
(?! ) Negative look-ahead assertion (for example, 'j(?!ohn)' matches 'j' in word 'june' but not in word 'john').
(?<= ) Positive look-behind assertion (for example, '(?<=joh)n' matches 'n' in word 'john' but not in word 'joan').
(?<! ) Negative look-behind assertion (for example, '(?<!joh)n' matches 'n' in word 'joan' but not in word 'john').

Within character classes "\b" represents backspace rather than a word boundary.

POSIX character classes

You can use following POSIX character classes:

Class Backslash Equivalent Meaning
alpha Alphabetic characters.
alnum Alphanumeric characters.
ascii ASCII characters.
cntrl Control characters.
digit \d Decimal digits.
graph Characters that are both printable and visible (a space is printable but not visible).
lower Lowercase alphabetic characters.
print Printable characters (characters that are not control characters).
punct Punctuation characters (characters that are not letters, digits, control characters, or space characters).
space \s Spacing characters (e.g. space, TAB, formfeed).
upper Uppercase alphabetic characters.
word \w Alphanumeric characters plus underscore ("_").
xdigit Characters that are hexadecimal digits.

You can negate the character classes by prefixing the class name with a '^'.

Usage: [[:alpha:]] (alphabetic characters), [01[:alpha:]%] (alphabetic characters plus 0, 1, and %), [[:^digit:]] (all characters except decimal digits).

Short forms of some character classes

You can use following short forms of character classes:

Class Meaning
\w Alphanumeric characters plus underscore ("_").
\W All characters except alphanumeric characters and underscore ("_").
\s Spacing characters (e.g. space, TAB, formfeed).
\S All characters except spacing characters (e.g. space, TAB, formfeed).
\d Decimal digits.
\D All characters except decimal digits.

Special characters

You can use following special characters:

Special character Meaning
\t tab
\n newline
\r return
\f formfeed
\a alarm (bell)
\b backspace
\x5A character 'Z' with ordinal 0x5A (hexadecimal value)