Regular expressions

From Tabbles wiki
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.

Contents

What are the regular expressions and how do they work?

- on wikipedia

- Page on Codeplex - 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)

$ = 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 anothe 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

Working regular expression - feel free to contribute :-)
Expression Effects Author
.*\.avi$|.*\.mov$|.*\.mpg$ matches .avi OR .mov OR .mpg 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 (post) KaptK


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

Personal tools
Namespaces

Variants
Actions
Navigation
Toolbox