Regular expressions

From Tabbles Wiki
Revision as of 17:09, 6 April 2018 by Andrea (talk | contribs) (Library of working regular expressions)
Jump to: navigation, search

Since the version 1.5.2 you can use regular expressions within the auto-tagging rules to tag files based on their name/path.

What are the regular expressions and how do they work?

- on wikipedia

- Page on Codeplex

- Online regular expression editor RegExr

- Download Expresso, a regular expression editor

- The reference page on MSDN

- Regular expression library (warning: the syntax could be different... the one on the MSDN page is the one that should work)

How do I use them in Tabbles?

Go to: Tools > Auto-tagging rules > New and edit the window to something like this:

regular_expressions.png


From now on, whenever you create/save/rename a file/folder that matches tha regular expression, the file will be tagged (and a one-click pop-up should come up too).

If you want to automatically tag the files you already have, you need to use the function Tools > Run rules now. In order to use this function you need to first select a folder/disk within Tabbles.

Pocket size tutorial

Let's analyze a working regular expression:

.*\.avi$|.*\.mov$|.*\.mpg$ This one matches .avi OR .mov OR .mpg. A little explanation:

.* = matches any character

\. = matches the character "." (the dot)

avi = matches the pattern "avi" (and also mov and mpg)

^ = beginning of the pattern to be matched (put this in the beginning of the thing you want to match)

$ = end of the pattern to be matched (append this at the end of the thing you want to match)

| = plain and simple logical OR


So, if you want to add another extension, like .mp3, you append |.*\.mp3$ to the previous expression.

Other interesting stuff:

\b = matches backslash, ^ = beginning of the line to be matched, the opposite of $

Well, the rest is in the msdn reference...

Library of working regular expressions

This is a list of working regular expression: to contribute or request new ones, post in the forum thread :-)


Expression Effects Author
.*\.avi$|.*\.mov$|.*\.mpg$ matches .avi OR .mov OR .mpg Andrea
.*England.*|.*Great.*Britain|.*United.*Kingdom.*|.*Northern.*Ireland|.*Wales.*|.*Scotland.* matches "Great Britain", "Great_Britain", "Great-Britain" (along with the rest of the UK) etc. Andrea
.*(201\d).* matches 2010 to 2019 (useful for years). Change "201" to "200" to match 2000 to 2009 Andrea
.*C\d{3}.* Matches files with a path like "D:\Customers\C001" to "C999" or "...\stuff_C001_stuff" (to ...C999) Andrea
[0-3][0-9][0-1][1-9]\d{2}-\d{4}?[^0-9]* Danish CPR Number (DDMMYY-NNNN, like 310180-1234) Andrea
.*\.(?:doc|pdf|chm|ppt|xls|rtf|docx|xlsx)$ matches .doc OR .pdf etc Renincuente
.*\b3x\d\d\b.* matches "season 3" (e.g. *3x01*,*3x01* etc) Maurizio
(?>.*\.)(?!(?:dll|cfg)$).*$ EXCLUDES .dll and .cfg files. Matches all the others Renincuente
(?:\w*_)?\d{2}-04-\d{4}(?:_\w*)? Matches pics taken in the month of April, named like Name_23-04-2010 or 23-04-2010_Name KaptK


Hint: be careful with the dots and the crazy characters - dont' lose half of them while copy-pasting!