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.

 
Reply to this topicStart new topic
> RegExp Help, Capitalize a letter after ( [ " ' when ( [ " ' precede
niche99
post Jul 28 2012, 04:40
Post #1


Member


Group: Members
Posts: 1
Joined: 28-July 12
Member No.: 16728
Mp3tag Version: 2.52



Hi,

I have tried the following with no success

regexp: (\s\'.)
replace: \U$0

and replaced the red character with [, " and ' with no consistent success.

For example the above regexp produces this:
The 'torchum' Never Stops -> The 'Torchum' Never Stops <- which I want.
The Massive Improve'lence -> The Massive Improve'Lence <- which I don't want.

Any help would be appreciated.
Regards,
niche99
Go to the top of the page
 
+Quote Post
stevehero
post Jul 28 2012, 11:20
Post #2


Member


Group: Full Members
Posts: 573
Joined: 3-December 10
From: Ireland
Member No.: 13334
Mp3tag Version: 2.65a



QUOTE (niche99 @ Jul 28 2012, 04:40) *
Hi,

I have tried the following with no success

regexp: (\s\'.)
replace: \U$0
....
For example the above regexp produces this:
The 'torchum' Never Stops -> The 'Torchum' Never Stops <- which I want.
The Massive Improve'lence -> The Massive Improve'Lence <- which I don't want.

Your action could not possibly work as \U in the replace is not how you go about doing this. It only works to find a non-upper case character anyway.
See http://help.mp3tag.de/options_format.html#regexp

For your problem try this.

Begin Action Group _Script Test#TEST

Action #1
Actiontype 4: Replace with regular expression
Field ______________: TITLE
Regular expression _: \s+'(.)
Replace matches with:
$upper($1)
[_] Case sensitive comparison

End Action Group _Script Test#TEST (1 Action)

This finds:
\s+ \s Space character unlimited times +
' The ' character
(.) Start capture ( with . representing any character and ) closing the capture

Replaces:
$upper Converts
($1) Captured like above

See http://help.mp3tag.de/main_scripting.html#general for more info.


This post has been edited by stevehero: Jul 28 2012, 11:31


--------------------
▶✚♬ ═‎​ ♡
Go to the top of the page
 
+Quote Post
DetlevD
post Jul 28 2012, 12:10
Post #3


Member


Group: Full Members
Posts: 5031
Joined: 26-May 06
From: Wuppertal, Germany, Planet Earth
Member No.: 3194
Mp3tag Version: 2.63



QUOTE (niche99 @ Jul 28 2012, 05:40) *
... The 'torchum' Never Stops -> The 'Torchum' Never Stops <- which I want.
The Massive Improve'lence -> The Massive Improve'Lence <- which I don't want. ...

The problem seems to be the punctuation mark "Apostroph", which is a word delimiter.
Therefore it is not so easy to code a lookbehind or lookahead.
But there is a workaround, which can help quickly.

For the capitalization use the function $caps2() and subsequently do the trick using the function $regexp().

$regexp($caps2(%FIELD%,' (["'),'(\s\x27)(.)','$1\u$2')

... or ...

$regexp($caps2(%FIELD%,' (["'),'\s\x27.','\U$0')

... or ...

$regexp(%FIELD%,'(^|\x20\x27|[[(\x20\x22])(.)','$1\u$2')

Apply the above expressions by action "Format value" or by converter "Tag - Tag".


If you want to apply the capitalization rule to all tag-fields at once, then use ...
Actiontype 4: Replace with regular expression
Field ______________: _TAG
Regular expression _: (^|\x20\x27|[[(\x20\x22])(.)
Replace matches with: $1\u$2
[_] Case sensitive comparison



Examples
the 'torchum' never stops -> The 'Torchum' Never Stops
the massive improve'lence -> The Massive Improve'lence
aaa bbb(ccc[ddd"eee 'fff -> Aaa Bbb(Ccc[Ddd"Eee 'Fff
aaa bbb(ccc[ddd"eee'fff 'ggg -> Aaa Bbb(Ccc[Ddd"Eee'fff 'Ggg



See also ...
http://forums.mp3tag.de/index.php?showtopi...ost&p=23265

DD.20120728.1314.CEST
Edit.DD.20120729.0842.CEST

This post has been edited by DetlevD: Jul 29 2012, 07:46


--------------------
* Beyond that, don't ask, when you don't know what to do with the answer. *
♥ home is where the heart is ♥
Go to the top of the page
 
+Quote Post
stevehero
post Jul 28 2012, 18:06
Post #4


Member


Group: Full Members
Posts: 573
Joined: 3-December 10
From: Ireland
Member No.: 13334
Mp3tag Version: 2.65a



QUOTE (DetlevD @ Jul 28 2012, 12:10) *
$regexp($caps2(%FIELD%,' (["'),'\s\x27.','\U$0')

The same not be done with:

Begin Action Group _Script Test#TEST

Action #1
Actiontype 4: Replace with regular expression
Field ______________: _TAG
Regular expression _: (\B|^)(\(|\[|"|')(.)
Replace matches with: $1$2$upper($3)
[_] Case sensitive comparison

End Action Group _Script Test#TEST (1 Action)

Resulting in:

(the [torchum' "never 'stops blank(the[torchum"never'stops >>>> (The [Torchum' "Never 'Stops blank(the[torchum"never'stops

by breaking up the different parts like not a word boundary OR start of string / (["'' / any one character to capture as $1, $2 & $3 (changed to upper-case) it seems to work. If you don't separate them like this you get unwanted results.

Plus one thing with using the action 'replace with regular expression' you can affect _TAG (All tags) like the example above whereas with the format action you can't.

Anybody know why mp3tag doesn't pick up the start of the string '(the [torchum' "never...' by using the \B. My fix was to put in a '|^' to fix the problem.

This post has been edited by stevehero: Jul 28 2012, 18:13


--------------------
▶✚♬ ═‎​ ♡
Go to the top of the page
 
+Quote Post

Reply to this 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 October 2014 - 13:58