ggarra13 / mrv2

Professional player and review tool for vfx, animation and computer graphics.
https://mrv2.sourceforge.io
BSD 3-Clause "New" or "Revised" License
197 stars 14 forks source link

Jumping Versions with regex #170

Closed jrsndl closed 7 months ago

jrsndl commented 9 months ago

Can you please point me to documentation on ow to write regex for detecting versions? It is great feature, but I can't make it to for for typical folder structrures like:

foo/shot_v001/shot_v001.1001.exr foo/shot_v002/shot_v002.1001.exr or bar/shot/v001/shot_v001.1001.exr bar/shot/v002/shot_v002.1001.exr

Thank you

ggarra13 commented 9 months ago

In principle, the default of _v should have worked for your first example (and I just checked it works me):

foo/shot_v001/shot_v001.1001.exr
foo/shot_v002/shot_v002.1001.exr

The actual regex that is created when you have "v" is the following: ` ([\w:/]*?[/.]_v)(\d+)([%\w\d./]*)`

You need to make the regex match three groups: a prefix([\w:/]*?[/\._]_v), the actual version (\d+) and the suffix ([%\w\d\./]*).

I think for your second example, the regex you may need might be:

([\w:/]*?[/\._]v)(\d+)([%\w\d\./]*)

jrsndl commented 9 months ago

In principle, the default of _v should have worked for your first example (and I just checked it works me):

it doesn't work for me (Windows 10, UNC path)

following: ([\w:/]?[/._]_v)(\d+)([%\w\d./]) Not sure what regex flavor is used, but it looks like some slashes need to be escaped? When I use this regex, or _v, mrv2 doesn't even show top menu Image item.

When I add (.*_v)(\d+)([%\w\d\.\/]*) instead, I see this in the log: image

When I try simple (.*_v)(\d+)(.*) that should match the first occurence of the _v in the path foo/shot_v001/shot_v001.1001.exr, the log is the same.

Maybe the regex is not counting with backslashes on Windows?

ggarra13 commented 9 months ago

Here's a regex that seems to work for me on Windows' UNC paths. Just copy it verbatim to the Preferences->Loading->Regex option:

([\w\\:/]*?[/\._]*_v)(\d+)([\w\d\./]*)

I've updated the default _v regex to match that. It will be there in v0.9.5 or when the beta finishes compiling on sourceforge.