Modify variables with regular expressions?

Started by lbo, March 13, 2021, 07:08:35 PM

Previous topic - Next topic

lbo

Hi,

can I manipulate variables with regular expressions?

For example, the regexp [^\.]{0,255} to strip everything from the first "." and limit the result to 255 characters?

This would be handy to get automated "headlines" from "descriptions" in a metadata template:

"Foobar bridge in Hamburg. The bridge is made from steel. Night shot." is then converted to "Foobar bridge in Hamburg".

Not a big deal if it isn't possible since the result has to be reviewed, anyway. And I can do it also with an exiftool one-liner.

Mario

#1
Variables allow regular expressions for filters. No regexp replace.

But maybe I can add a before / after / between with regep support for IMatch 2021. May be useful for many...
Feel free to add a feature request.
-- Mario
IMatch Developer
Forum Administrator
http://www.photools.com  -  Contact & Support - Follow me on 𝕏 - Like photools.com on Facebook

lbo

Quote from: Mario on March 13, 2021, 07:33:29 PM
Variables allow regular expressions for filters. No regexp replace.

Thanks for confirming that I didn't miss something in the docs.

ExifTool -headline<${description;s/([^\.]{0,255}).*/$1/} seems to do the job.

Quote from: Mario on March 13, 2021, 07:33:29 PM
But maybe I can add a before / after / between with regep support for IMatch 2021. May be useful for many...

I don't know the capabilities of the RE engine in IMatch, but wouldn't it be simpler to implement (and more powerful) to make the RE matching groups accessible?

For example, I use ExifTool to repair weird (sorry, US readers) dates in PDF files with s[(\d{1,2})/(\d{1,2})/(\d{4})][$3:$1:$2]

Mario

Most users don't even understand regular expressions, me included.
This seems to be a very special use case. You can do it with ExifTool. Feel free to add a FR but I doubt more than one user will ever need this.
-- Mario
IMatch Developer
Forum Administrator
http://www.photools.com  -  Contact & Support - Follow me on 𝕏 - Like photools.com on Facebook