First, a massive thank you for the program, it has been very helpful to me and I am grateful that you make it available for free.
I just updated to v4.0.0.5, and the bug fix for the parenthesis in regex replace now seems not to be working 100% as expected for v2 regex conditional replaces using the Boost syntax.
I use the below regex, designed to swap a date in the file name with a name in two words following it (named group N1).
The name can be followed by anything (named group T), and in the output I want the segments separated by dashes, but the last dash should only appear if named group T is available, so I use the conditional Boost replacement sub-expression syntax using "?" (marked here in red), with only a true-expression to insert a dash and named group T:
(.+?) (\d{2,}).(\d\d).(\d\d) (?<N1>\w+ \w+)(?<T> .+)?
\1 - $+{N1} - \2.\3.\4(?{T} -$+{T})
Example input and expected output:
youtube 2004.07.12 tim tom a lovely time
youtube - tim tom - 2004.07.12 - a lovely time
This previously worked.
However, with the latest update, the brackets in the output expression are now also appearing in the output, I get this as output filename:
youtube - tim tom - 2004.07.12( - a lovely time)
The Boost documentation states:
(https://www.boost.org/doc/libs/1_87_0/libs/regex/doc/html/boost_regex/format/boost_format_syntax.html)
Boost-Extended Format String Syntax
Boost-Extended format strings treat all characters as literals except for '$', '\', '(', ')', '?', and ':'.
Grouping
The characters '(' and ')' perform lexical grouping, so use \( and \) if you want a to output literal parenthesis.
Conditionals
The character '?' begins a conditional expression, the general form is:
?Ntrue-expression:false-expression
where N is decimal digit.
If sub-expression N was matched, then true-expression is evaluated and sent to output, otherwise false-expression is evaluated and sent to output.
You will normally need to surround a conditional-expression with parenthesis in order to prevent ambiguities.
For example, the format string "(?1foo:bar)" will replace each match found with "foo" if the sub-expression $1 was matched, and with "bar" otherwise.
For sub-expressions with an index greater than 9, or for access to named sub-expressions use:
?{INDEX}true-expression:false-expression
or
?{NAME}true-expression:false-expression
I'd appreciate it if you would like to check if I am correct in concluding that this is undesired behaviour, as the parenthesis should not be treated as output characters.
In this case, I have a simple workaround as the conditional expression is at the end of the filename so I can simply leave out the parenthesis, but I have others where the conditional expression appears in the middle of the regex replace, and I do have to use parentheses in those cases to group the conditional expression and its sub-expressions.
Kind regards, and thank you again for the hard work on the program,
Eelco