

Regular Expressions (RegEx) is a syntax for specifying patterns of text to search and replace, which can be used for renaming files via the Regular Expressions renaming rule.

If more than one group is used the next group name will be \2. The value of the special metacharacter \1 is in this case "123". If the filename contains "zip_123" the filename will contain "123_zip" after the method has been applied.

If in the replace method we put "\1_zip" in the second text field the result will show that the two parts of the filename have changed place. The match is exactly the same as before except now we can access the value of the subpattern in a replace scenario. A group is defined by enclosing a part of the pattern in a parenthesis (). Advanced Renamer supports the use of regular expressions for pattern searching. It is possible to define subpatterns within the pattern itself which proves very useful when using the replace method. A regular expression language is a powerful way of manipulating with texts.
Regex renamer plus#
The plus + will match the previous character 1 or more times which means that this expression will match "zip_123" and "zip_1234" and "zip_8000000".

If we don't know how many digits there are we can use another meta character.
Regex renamer code#
What if we don't know how many numbers a zip code consists of? What if some files contain "zip_123" and others "zip_384739"? The above expression will only match if there are exactly 4 digits. If you in the first text field type the above expressions "zip_\d\d\d\d" and in the second text field type "zip_unknown" any file containing "zip_" followed by 4 digits will get this text phrase replaced by "zip_unknown". The most common method with regex support is the Replace method. The above expression matches any phrase starting with "zip_" followed by 4 digits. The "\d" is a metacharacter which represent any numeric value raging from 0 to 9. Given the expression above the resulting match of a filename "BayTower_zip_4500.txt" will be "zip_4500". Let's start out with a simple expression: The normal characters are interpreted as they are while the metacharacters have special meaning. This page will try to give you basic knowledge about the use of regular expressions in the context of file renaming.Ī regular expression contains normal characters and metacharacters. Those learning this for the first time will also be able to use the skills in other similar tools. A standard library called PCRE is used which means that people with prior knowledge of this library will feel right at home. The use of these expressions is primarily meant for power users and people with programming experience but none the less gaining knowledge of the basics will prove to be very rewarding. Advanced Renamer supports the use of regular expressions for pattern searching and replacing in several methods. A regular expression language is a powerful way of manipulating with texts.
