RegEx date as YYMMDD in Save Documents

This Forum is for the use of End Users requiring help and assistance for Tracker Software's PDF-Tools.

Moderators: PDF-XChange Support, Daniel - PDF-XChange, Chris - PDF-XChange, Sean - PDF-XChange, Vasyl - PDF-XChange, Stefan - PDF-XChange

rgegges
User
Posts: 1
Joined: Thu Jun 05, 2025 6:18 am

RegEx date as YYMMDD in Save Documents

Post by rgegges »

Hello

I can find successfully a date in the document DD.MM.YY or DD.MM.YYYY
\d{2}\.\d{2}\.\d{2}(?:\d{2})?
and save it to Date1

I can name the Document %[RegExp:Date1] %[FileName]
DD.MM.YYYY SoAndSo.pdf

But i need the filename of the document to be
YYYY MM DD SoAndSo.pdf

The Tooltip in RegExp says:
"You can use found text in the actions for saving documents
and changing document settings using the macro syntax
%[RegExp:Date1]. To reference a group in a hit to
, use the syntax %[RegExp:Date1.Index]"

Some of my unsuccessful trys
%[RegExp:Date1.3] %[RegExp:Date1.2] %[RegExp:Date1.1] %[FileName]
%[RegExp:Date1.2] %[RegExp:Date1.1] %[RegExp:Date1.0] %[FileName]

What is the correct syntax ??
User avatar
Vladimir G - Tracker Dev
User
Posts: 75
Joined: Thu Nov 30, 2017 1:24 pm

Re: RegEx date as YYMMDD in Save Documents

Post by Vladimir G - Tracker Dev »

Hello Rgegges,

1. To refer to different parts of a date, you need to define a matching group for each part of interest by enclosing the group pattern in parentheses.
2. You should use a comma, not a dot, when referring to a matched group in a macro expression:

Code: Select all

%[RegExp:Date1,1]
but not

Code: Select all

%[RegExp:Date1.1]
I suggest the following regular expression to match a date:

Code: Select all

(\d{2})\.(\d{2})\.(\d{4}|\d{2})
It has three matching groups:
(\d{2}) - two-digit number (DD)
(\d{2}) - two-digit number (MM)
(\d{4}|\d{2}) - either a two-digit or four-digit number (YY or YYYY). Note: It's important to put \d{4} before \d{2} to ensure four-digit years are matched first.

Then, for the Filename option in the Save Documents action, use the following expression:

Code: Select all

%[RegExp:Date1,3] %[RegExp:Date1,2] %[RegExp:Date1,1] %[FileName]
I've attached a ZIP with the tool export with all necessary options configured — feel free to test it and adjust it to your needs.
RegExp Date.zip
or you can take a look at the screenshot of the tool settings:
image.png
Best regards,
You do not have the required permissions to view the files attached to this post.
Vladimir Goshko
Software Developer
PDF-XChange Co. LTD