IPB

Welcome Guest ( Log In | Register )

> Notice!

Please take a minute to check our Frequently Asked Questions. Use Search to reveal possible related topics.

Also make sure you've read the Forum Guidelines before posting in this forum.

> Regular Expressions, Examples of actions with Regular Expressions
Florian
post Oct 16 2003, 19:47
Post #1


Developer


Group: Admin
Posts: 7703
Joined: 12-December 01
From: Germany, Dresden
Member No.: 203
Mp3tag Version: 2.61d



This thread collects some useful regular expressions.

If you created a regular expression which solves a common task, please post it here and give a short description what it is supposed to do.

These regular expressions can be used with the action type Replace with regular expression. Please look at FAQ: How do I create a new action? to learn more about actions in Mp3tag.

-> If you have problems with a regular expression, please open a separate topic.


--------------------
♫ If you like using Mp3tag please donate to support further development.

Go to the top of the page
 
+Quote Post
 
Start new topic
Replies
Juozas V
post Dec 15 2010, 02:39
Post #2


Member


Group: Members
Posts: 1
Joined: 15-December 10
From: Edinburgh, United Kingdom
Member No.: 13412
Mp3tag Version: 2.47a



Script to fix capitalization according to English rules only in tags. This is my n-th attempt to do this, but I think it works quite nice... Of course some human work is needed because it doesn't contain corpus to check it according to its POS.

CODE
[#0]
T=1
F=_TAG
1=1
2=

[#1]
T=4
F=_TAG
1=\\b(A|An|The|And|But|Or|So|After|Before|Out|When|While|Since|Until|Although|Even If|Because|About|Above|Across|Against|Along|Alongside|As|At|Below|By|During|For|
From|In|Into|Of|Off|On|Onto|Over|Than|Through|Till|To|Under|Up|With|Within|Witho
u
t)\\b
2=$lower($1)
3=0

[#2]
T=4
F=_TAG
1=^\\s*(\\w+)
2=$caps($1)
3=0

[#3]
T=4
F=_TAG
1=(\\w+)\\s*$
2=$caps($1)
3=0


Or directly in mp3tag:
Case conversion
Field _TAG
Case conversion Mixed Case
Words begin...

Replace with regular expression
Field _TAG
Regular expression \b(A|An|The|And|But|Or|So|After|Before|Out|When|While|Since|Until|Although|E
ven If|Because|About|Above|Across|Against|Along|Alongside|As|At|Below|By|During|For|
From|In|Into|Of|Off|On|Onto|Over|Than|Through|Till|To|Under|Up|With|Within|Withou
t)\b
Replace matches with $lower($1)

Replace with regular expression
Field _TAG
Regular expression ^\s*(\w+)
Replace matches with $caps($1)

Replace with regular expression
Field _TAG
Regular expression (\w+)\s*$
Replace matches with $caps($1)

This post has been edited by Juozas V: Dec 15 2010, 02:47
Go to the top of the page
 
+Quote Post
Doug Mackie
post Jan 13 2011, 19:55
Post #3


Member


Group: Full Members
Posts: 35
Joined: 27-April 09
From: New Jersey, USA
Member No.: 9952
Mp3tag Version: 2.51



To Juozas V:
Thank you very much for this. It does the best English title case conversion that I have seen here.

However, I have one minor quibble. Your word list includes some words and phrases that I see more often used in song titles as subordinate conjunctions than as prepositions. For example "after", "because", and "although". From my reading on capitalization in titles, subordinate conjunctions should always be capitalized. Since it's not practical to use script to detect how a word is used, I chose to remove those words from your Reg Ex on the basis that there should be fewer errors without them than with them. The words that I removed are:

After, As, Although, Because, Even If, Since, Till, Until, When, and While.

Here is my revised word list (resorted alphabetically):

A|About|Above|Across|Against|Along|Alongside|An|And|As|At|Before|Below|But|By|Du
ring|For|From|In|Into|Nor|Of|Off|On|Onto|Or|Out|Over|So|Than|The|Through|To|Unde
r
|Up|With|Within|Without


Note that I also added the coordinating conjunction "Nor" to your list.

Best regards,
Doug M. in NJ

This post has been edited by Doug Mackie: Jan 13 2011, 19:58
Go to the top of the page
 
+Quote Post

Posts in this topic
- Florian   Regular Expressions   Oct 16 2003, 19:47
- - Florian   Re: Regular Expressions   Oct 16 2003, 19:52
- - areve   Re: Regular Expressions   Oct 16 2003, 20:42
|- - gingernob   QUOTE (areve @ Oct 16 2003, 21:42) Regula...   Jun 19 2011, 18:06
- - areve   Here is another one. I don't think it will be ...   Dec 4 2003, 20:05
- - phoenixdarkdirk   This regular expression fixes tracknumbers from iT...   Apr 11 2004, 20:50
- - areve   Another one, that switches first and last names (f...   May 30 2004, 21:20
|- - incifinci   Switches first and last names QUOTE (areve ...   Feb 19 2010, 10:24
- - mll   Used to use this basic regexp : Applied on TRACK,...   Jul 14 2004, 10:27
- - ThurstonX   If you have a filename:01 Tracknameand want it to ...   Jul 31 2004, 23:34
- - RevRagnarok   I've noticed a lot of these RegExs 'go ove...   Nov 18 2004, 12:23
|- - Florian   RevRagnarok, QUOTE (RevRagnarok @ Nov 18 200...   Nov 18 2004, 14:34
|- - nickless   This RegEx will convert abbreviations composed of ...   Mar 29 2005, 22:22
- - ThurstonX   Title Tag Conversion This 2-step action does: 1....   Oct 15 2005, 02:01
- - dano   Upper case for Roman numbers Regular expression: ...   Dec 28 2005, 16:12
- - Snykch   Convert artist names in the form 'Artist, The...   Feb 19 2006, 15:35
- - Michaelm   And the other way around Move "The " to...   Apr 22 2006, 13:56
- - Fan o blues   It's taken me far too long to figure it out bu...   Mar 25 2007, 20:05
|- - Craig   QUOTE (Fan o blues @ Mar 25 2007, 19:05) ...   Mar 14 2009, 14:59
- - neilpa   This regex can remove/replace all but the last dot...   Nov 20 2007, 07:16
- - Nathan   I recently converted all my wma files to mp3 only ...   Jan 22 2008, 01:13
- - Harakiri   Another member helped me creating one of the most ...   Sep 1 2008, 23:02
- - KCE   Really simple but this will remove any parenthesis...   Oct 24 2008, 23:08
|- - Lebon14   QUOTE (KCE @ Oct 24 2008, 17:08) Really s...   Nov 8 2009, 05:23
- - captainmidnight   I dislike it when a leading zero appears in the tr...   Dec 5 2008, 04:56
|- - captainmidnight   Actually, here is a single regex that does everyth...   Dec 5 2008, 05:17
- - Florian   I've split some off-topic posts to Problem wit...   Nov 8 2009, 20:43
- - MatthiasM   This is not a regular expression for mp3tag, but a...   Nov 19 2009, 10:48
- - Zoofield   These are my Reg-Expressions there may be duplicat...   Jun 27 2010, 19:34
- - d003232   My title and/or filename looks like: Gospel&s...   Aug 16 2010, 11:38
|- - DetlevD   QUOTE (d003232 @ Aug 16 2010, 12:38) ...G...   Aug 16 2010, 17:22
|- - RevRagnarok   QUOTE (d003232 @ Aug 16 2010, 06:38) I do...   Aug 17 2010, 13:57
- - DetlevD   Roman numerals in uppercase This "Regular Ex...   Aug 31 2010, 10:33
- - DetlevD   Splitting an "Upper Camel Case" string ...   Sep 17 2010, 18:02
- - InspectorMustache   QUOTE (nickless @ Mar 29 2005, 22:22) Thi...   Dec 6 2010, 01:09
- - Juozas V   Script to fix capitalization according to English ...   Dec 15 2010, 02:39
|- - Doug Mackie   To Juozas V: Thank you very much for this. It doe...   Jan 13 2011, 19:55
- - DetlevD   Regular Expression Tutorial Beginner or Professio...   Jan 10 2011, 19:09
|- - pone   ZITAT(DetlevD @ Jan 10 2011, 19:09) Regul...   Jan 10 2011, 21:02
|- - DetlevD   QUOTE (pone @ Jan 10 2011, 21:02) Are all...   Jan 10 2011, 21:09
- - LosMintos   Convert MP3tag's date to ISO date Converts (e...   Apr 18 2011, 20:55
- - Zoofield   I could not get, "DetlevD - Splitting an Uppe...   Jun 10 2011, 22:17
- - tobi06   To remove any website in the filename example: ...   Jun 18 2011, 11:01
- - dano   I've added an example without dash to that pos...   Jun 19 2011, 20:14
|- - gingernob   QUOTE (dano @ Jun 19 2011, 21:14) I'v...   Jun 20 2011, 01:39
- - DetlevD   Convert from RFC822/1123 Date string to ISO-8601 D...   Aug 1 2011, 05:03
|- - Luctus   QUOTE (DetlevD @ Aug 1 2011, 06:03) Conve...   Mar 10 2014, 18:36
|- - DetlevD   QUOTE (Luctus @ Mar 10 2014, 18:36) Can y...   Mar 10 2014, 22:38
- - DetlevD   How to copy a list of artists and their roles ... ...   Aug 24 2011, 15:55
|- - pone   ZITAT(DetlevD @ Aug 24 2011, 16:55) ...   Aug 24 2011, 16:29
|- - DetlevD   QUOTE (pone @ Aug 24 2011, 17:29) What is...   Aug 24 2011, 16:48
- - naisanza   If you want to add TEXT to the existing tag: Regu...   Feb 8 2013, 00:55
|- - RevRagnarok   QUOTE (naisanza @ Feb 7 2013, 18:55) Regu...   Apr 5 2013, 10:41
- - dano   It's not a bug. It happens because global matc...   Apr 5 2013, 13:39


Closed TopicStart new topic
1 User(s) are reading this topic (1 Guests and 0 Anonymous Users)
0 Members:

 



RSS Lo-Fi Version Time is now: 30th July 2014 - 06:00