File Matching Expressions using Regular Expressions
Regular expressions can be created using Regex Builder tool.
Each regular expression must start with a definition of the local drive or network share drive, followed by one or more subfolder with a without specified name. It also requires at least one folder that determines the contract number. When saving a regular expression, you must give it a document category name.
Example 1:
(\\\\)Imgsvr05(\\)(\w[\w ]*)\\Jobs(\\)(?<ContractNo>\w+)\\Contract
Explanation of each part of the regular expression:
(\\\\)Imgsvr05 : drive
(\w[\w ]*) : subfolder with any name
Jobs : Jobs subfolder (this subfolder name must be Jobs)
(?<ContractNo>\w+): subfoder that determines the contract number of the document
Contract: Contract subfolder (this subfolder name must be Contract)
The following folder paths would match the above regular expression:
\\imgsvr05\temp\Jobs\333\Contract
\\imgsvr05\test\Jobs\333\Contract
* Contract number extracted from the above valid paths will be 333
The following folder paths would not match the above regular expression:
\\imgsvr05\temp\Jobs\333\Photo
\\imgsvr05\temp\Test\333\Contract
Example 2:
(?<Drive>[a-zA-Z])(:)(\\)(\w[\w ]*)\\Jobs(\\)(?<ContractNo>\w+)(\\)(?<ContractNo>\w+)\\Plan
Explanation of each part of the regular expression:
(?<Drive>[a-zA-Z])(:): local drive
(\w[\w ]*) : subfolder with any name
Jobs : Jobs subfolder (this subfolder name must be Jobs)
(?<ContractNo>\w+): subfoder that determines the contract number of the document
Plan: Plan subfolder (this subfolder name must be Plan)
The following folder paths would match the above regular expression:
D:\temp\Jobs\123\45a\Plans
C:\test\Jobs\123\45b\Plans
*Contract numbers extracted from the above valid paths will be 12345a and 12345b
The following folder paths would not match the above regular expression:
D:\temp\Test\123\45a\Photo
D:\temp\Test\123\45b\Contract
Below are some sample regexes:
Regex - (?<Drive>[a-zA-Z])(:)(\\)Data(\\)Job-Docs(\\)Jobs(\\)(\w*)(\W)(\w)*(\\)(?<ContractNo>\w+)(\\)XXClickHome(\\).*
Would match to E:\Data\Job-Docs\Jobs\ 33101-33200\33173\XXClickHome\
if there was a job with Jobnumber 33173
fkidOther must be the relevant document category Id (see tblDocCategories.idDocumentCategory)
sgValue must be either L, P or C
Regexes can be tested here: (Works on IE only)
More examples of Regexes:
(\\\\)Server Name(\\)Jobs(\\)(\w[\w ]*)(\\)(\w[\w &^#@%$()*+=!'-{}<>,.`~|?[]*)\s+(?<ContractNo>\w+)(\\)photos(\\).* example folder: \\Server Name\Jobs\B\Booth 30694\PHOTOS\cabinets 001.jpg
(\\\\)Server Name(\\)Jobs(\\)(\w[\w ]*)(\\)(\w[\w &^#@%$()*+=!'-{}<>,.`~|?[]*)\s+(?<ContractNo>\w+)(\\)FWDs, Layouts & Components(\\).*
(\\\\)Server Name(\\)Jobs(\\)(\w[\w ]*)(\\)(\w[\w &^#@%$()*+=!'-{}<>,.`~|?[]*)\s+(?<ContractNo>\w+)(\\)Maintenance(\\).*
(\\\\)Server Name(\\)Jobs(\\)(\w[\w ]*)(\\)(\w[\w &^#@%$()*+=!'-{}<>,.`~|?[]*)\s+(?<ContractNo>\w+)(\\)Supervisor(\\).*
(\\\\)Server Name(\\)Jobs(\\)(\w[\w ]*)(\\)(\w[\w &^#@%$()*+=!'-{}<>,.`~|?[]*)\s+(?<ContractNo>\w+)(\\)Variations - Signed(\\).*
(\\\\)Server Name(\\)Jobs(\\)(\w[\w ]*)(\\)(\w[\w &^#@%$()*+=!'-{}<>,.`~|?[]*)\s+(?<ContractNo>\w+)(\\)Shire - Approved Docs(\\).*
Examples for PO Linking
(?<Drive>[a-zA-Z])(:)(\\)GrovellerTesting(\\)(?<ContractNo>[^\\]+)(\\)POs(\\)(?<PONumber>.+)\.pdf$
If excluding a specific folder, such as 'Superceded', then add at the end of the regex:
(\\\\)Server Name(\\)Jobs(\\)(\w[\w ]*)(\\)(\w[\w &^#@%$()*+=!'-{}<>,.`~|?[]*)\s+(?<ContractNo>\w+)(\\)01 Drafting PDFs(\\)((?!Superceded).)*$
If excluding all subfolders
(\\\\)Server Name(\\)Jobs(\\)(\w[\w ]*)(\\)(\w[\w &^#@%$()*+=!'-{}<>,.`~|?[]*)\s+(?<ContractNo>\w+)(\\)01 Drafting PDFs(\\)((?!.*\\)).*
If you need to change the way we use 'named capture groups' [like (?<ContractNo>\w+) ] then use this link as there is some great information available - https://riptutorial.com/regex/example/2530/what-a-named-capture-group-looks-like
One example is if there is a full stop in the folder name for the contract number, in which case use (?<ContractNo>[\w.]+) and that will not treat the full stops as pauses which is the regular use for them in a Regex.