Difference between revisions of "Regular expressions"

From Tabbles Wiki
Jump to: navigation, search
(Library of working regular expressions)
m (Library of working regular expressions)
Line 58: Line 58:
 
|  <nowiki>.*\.avi$|.*\.mov$|.*\.mpg$</nowiki> || matches .avi OR .mov OR .mpg  || Andrea
 
|  <nowiki>.*\.avi$|.*\.mov$|.*\.mpg$</nowiki> || matches .avi OR .mov OR .mpg  || Andrea
 
|-
 
|-
|  <nowiki>.*England.*|.*Great.*Britain|.*United.*Kingdom.*|.*Northern.*Ireland|.*Wales.*|.*Scotland.*</nowiki> || matches "Great Britain", "Great_Britain", "Great-Britain" etc.  || Andrea
+
|  <nowiki>.*England.*|.*Great.*Britain|.*United.*Kingdom.*|.*Northern.*Ireland|.*Wales.*|.*Scotland.*</nowiki> || matches "Great Britain", "Great_Britain", "Great-Britain" (along with the rest of the UK) etc.  || Andrea
 +
|-
 +
|  <nowiki>.*(201\d).*</nowiki> || matches 2010 to 2019 (useful for years). Change "201" to 200 to match 2000 to 2009 || Andrea
 
|-
 
|-
 
|  <nowiki>.*\.(?:doc|pdf|chm|ppt|xls|rtf|docx|xlsx)$</nowiki> || matches .doc OR .pdf etc || Renincuente
 
|  <nowiki>.*\.(?:doc|pdf|chm|ppt|xls|rtf|docx|xlsx)$</nowiki> || matches .doc OR .pdf etc || Renincuente

Revision as of 11:32, 6 April 2018

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 - 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 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

Working regular expression - feel free to contribute :-)
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
.*\.(?: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!