Various simple rename presets

Saw the regex and thought it couldn't be right. And indeed: it kept the dot between '9.1.0.6' and 'x86'

Alternative:
(with Ignore extension enabled)
Old name: (\D)\.|\.(\D)
New name: \1 \2

In detail:
\D = any character, but not a number
\. = a literal "."
| = OR

(\D)\.|\.(\D)
 \1       \2

So ...

  1. A "not a number", IF followed by a dot, will be replaced by \1 (= "not a number" ) and a space
    (there is no \2 in this case)
  2. A dot, IF followed by a "not a number" will be replaced by a space and \2 (= "not a number")
    (there is no \1 in this case)

My actual question:
It looks like regex lookbehind is not supported (I can't even type or paste a "<" in the Old Name).
What regex engine and version is being used in Opus?
I expect it to be the ECMAscript flavour, but confirmation would be nice.

ECMAScript (via Visual Studio's C++ STL).

Syntax is documented here:

1 Like

Thanks! :thumbsup:

1 Like

@NotNull
Evaluator can easily verify that a capture group is Null.
Now we even have a null-coalescing operator .
Here is a similar regular expression that pads words in brackets with a space.

I use this example only because I already had a saved copy.
In this screenshot I am testing each iteration to see if capture group 4 is really null or not.

The RegEx looks outdated because when these were first done, Directory Opus didn't support ignore extension, at least as I remember, and back then we had an earlier RegEx library.

This ad-hoc Script Editor is quite useful. Thanks for the tip!

The iterations are necessary because this regex "works his way back" from the end to the beginning of the name.
When going in the other direction, there are no iterations and only the capture group(s) of the very first match will be shown.

Like in the example below: There will not be a \2 to output
( test with x = RegEx(name, "(\[)(?![ \]])|([^ \[])(?=\])", "\2");


Ad-Hoc Script

name = "[echo]-[echo]-[echo]-[echo]-[echo].txt";

x = "";
newname = "";

output(concat(2, "Origiinal name  = ", name));
Output("");

for ( i = 0; i <=10; i++ )
{
	Output(concat(2, "=== Pass ", i));
	x = RegEx(name, "(\[)(?![ \]])|([^ \[])(?=\])", "\1");
	Output(Concat(2, "x = ", x ?? "Null"));
		
	newname = RegExS(name, "(\[)(?![ \]])|([^ \[])(?=\])", "\1\2 ");
	name == newname ? { Output("name = newname; we're done"); break;} : Output(Concat(2, " newname = ", newname ));
	name = newname;
}

Output("");
Output(Concat(2, "Final result = ", newname ));


Output:

Origiinal name  =  [echo]-[echo]-[echo]-[echo]-[echo].txt

=== Pass  0
x =  [
 newname =  [ echo ]-[ echo ]-[ echo ]-[ echo ]-[ echo ].txt
=== Pass  1
x =  [ echo ]-[ echo ]-[ echo ]-[ echo ]-[ echo ].txt
name = newname; we're done

Final result =  [ echo ]-[ echo ]-[ echo ]-[ echo ]-[ echo ].txt
--> (empty result)
1 Like

Thanks Much !
I am looking into this.
Positive and Negative Asserts are new to me.

One result that differs from my version are multiple brackets.
My version ensures a space character within only the innermost bracket set unless there is a word outside of that and I'm not sure that was done right.
Your reworked version ensures a space within each nested bracket set.
Nothing wrong with that, it is only a matter of personal opinion.

I'm busy and away the next few days as I was today, but I'll try to take a laptop with so I can work on this a bit more.