BDO TOOLS  -  Rename Files Remove Duplicates Replace Characters

Regular Expressions



Important
Regular Expressions in BDO Tools process only the filename part of files' names. File extensions are not included in the pattern match.

Example
Consider the first file listed above, 13th Letter, The (1951).avi. Ignoring the extension, the string 13th Letter, The (1951) will be processed by the Regular Expression in the Match box.

The Regular Expression in the Match box above contains 5 capture groups (CG), each capture group 'ending' the preceding one.
From left to right, the CGs above are numbered:

# Capture Group Description Match
1 ([^I].*) Matches zero or all characters .* in a filename up to a comma-space combination (CG 2), except filenames starting with the letter I - [^I]. '13th Letter'
2 (, ) Matches a comma-space combination of characters in the filename, if such a combination exists. ', '
3 (.*) Matches zero or all characters that follow the comma-space combination (CG 2), up to an opening parenthesis (CG 4). 'The '
4 (/(/d{4}/)) Matches an opening parenthesis /( followed by exactly 4 digits /d{4} followed by a closing parenthesis /). '(1951)'
5 (.*) Matches zero or more characters .* in the filename after CG 4. ''


The CGs in the example above are referred to in the Replace with box using backreferences, where \1 refers to CG 1 and \3 refers to CG 3, etc..
The result of the example above is The 13th Letter (1951). BDO Tools then adds the extension, as shown in the Example box above.

Regular Expressions

BDO Tools uses PCRE. The following is a very small subset of the available syntax.
      Special Characters
             .        Matches any character, except a newline or line terminator
             \w       Matches a word character
             \d       Matches a digit
             \s       Matches a whitespace
             \0       Matches a NULL
             \n       Matches a new line
             \f       Matches a form feed
             \r       Matches a carriage return
             \t       Matches a Tab
             \oN      Matches the character specified by octal N
             \xN      Matches the character specified by hexadecimal N
             \uN      Matches the Unicode character specified by hexadecimal N
             ()       Creates a capture group
             []       Creates a character set

         Quantifiers
             s+       Matches any string that contains at least one letter s
             s*       Matches any string that contains zero or more occurrences of the letter s
             s?       Matches any string that contains zero or one occurrences of the letter s
             s{n}     Matches any string that contains a sequence of n s's
             s{n,m}   Matches any string that contains a sequence of n to m s's
             s{n,}    Matches any string that contains a sequence of at least n s's
             s$       Matches a string ending with the letter s
             ^s       Matches a string beginning with the letter s
             e(?=s)   Matches the letter e when it’s followed by the letter s
             e(?!s)   Matches the letter e when it’s not followed by the letter s
      
 
Copyright © 2018 Brian D. Ogilvie www.bdozone.com  :