Page 9 of 102

Re: RegExp Find & Replace 2.2.2 - with 50 presets [MM2+3]

Posted: Mon Aug 25, 2008 2:24 am
by nynaevelan
Hi:

I need a little help again. I would like to setup a preset that would search the lyrics field for any non-English alphabet characters, is this possible? I don't need to replace them, I just want to identify them in order to replace the lyrics with a different script.

Nyn

Re: RegExp Find & Replace 2.2.2 - with 50 presets [MM2+3]

Posted: Mon Aug 25, 2008 7:00 am
by ZvezdanD
nynaevelan wrote:I would like to setup a preset that would search the lyrics field for any non-English alphabet characters, is this possible?
Of course it is possible. For example you could take a look on the "Capitalize the Title (ASCII, Latin 1, Latin 2 & Cyrillic)" preset which contains character ranges.

If you want to find a field which contain English alphabet characters, you should write the next string for the Find what:

Code: Select all

[A-Za-z]
Now, if you want just opposite, i.e. to find any character which is not English alphabet, you should add "^" inside of the brackets on the begin:

Code: Select all

[^A-Za-z]
However, there is a problem with such string because it would match all non-alphabet characters like numbers, punctuation... So, it is the best if you specify all character ranges which you want to find - [\xDF-\xF6\xF8-\xFF] is Latin1, [\u0100-\u024F] is Latin2 and [\u0400-\u04FF] is Cyrillic. If you want to cover all of this ranges, you should write:

Code: Select all

[\xDF-\xF6\xF8-\xFF\u0100-\u024F\u0400-\u04FF]
nynaevelan wrote:I don't need to replace them, I just want to identify them in order to replace the lyrics with a different script.
I don't know exactly what you want, but I think that even this could be done automatically with this script.

Re: RegExp Find & Replace 2.2.2 - with 50 presets [MM2+3]

Posted: Mon Aug 25, 2008 8:03 am
by nynaevelan
Will you examples catch Chinese characters also?

Nyn

Re: RegExp Find & Replace 2.2.2 - with 50 presets [MM2+3]

Posted: Mon Aug 25, 2008 9:02 am
by ZvezdanD
nynaevelan wrote:Will you examples catch Chinese characters also?
No, it will match only Latin 1, Latin 2 and Cyrillic. If you are interested about character ranges, please take a look on http://www.unicode.org/Public/UNIDATA/Blocks.txt or http://www.regular-expressions.info/unicode.html.

Anyway, if you want to find all non-ASCII characters, you could try with:

Code: Select all

[^\x20-\x7F]
or:

Code: Select all

[^\u0020-\u007F]

Re: RegExp Find & Replace 2.2.2 - with 50 presets [MM2+3]

Posted: Fri Aug 29, 2008 10:43 pm
by barkoz
I need a little help, I am trying to remove the timing marks from LRC lyrics
From this
[00:13]E già
[00:15]Io sto sempre con gli altri
[00:19]Però

and get this
E già
Io sto sempre con gli altri
Però

In Find What I put [:\d] using regular expression 1 and that gives me
[]E già
[]Io sto sempre con gli altri
[]Però

Is there any way of removing all, those brackets are killing me, I will never get to sleep tonight. :o :o :o
Any help would be much appreciated
Cheers from down here.


EDIT
Never mind... I got it. Had to use
[][:\d]
I Love This Script

Re: RegExp Find & Replace 2.2.2 - with 50 presets [MM2+3]

Posted: Sat Aug 30, 2008 5:41 am
by ZvezdanD
barkoz wrote:Never mind... I got it.
Glad you found your way to do this. :) However, I think this is not the best approach for such thing because it would remove all occurrences of specified characters, even if they are not a part of timing marks - "[", "]", ":" and digits from "0" till "9". This is because square brackets are reserved characters in RegExp and they are used for specifying character classes. If you want to specify square brackets as plain characters you should put backslash in the front of them - \[ and \].

There are several more appropriate solutions to your request, here is the simplest one:

Code: Select all

\[\d\d:\d\d\]
If you want more complicated one, you could check if a position of matched characters are on the begin of each line, for example:

Code: Select all

(^|\r\n)(\[\d\d:\d\d\])
but in this case you should use $1 as a Replace with string.

Re: RegExp Find & Replace 2.2.2 - with 50 presets [MM2+3]

Posted: Tue Sep 02, 2008 1:24 pm
by djo4ever
Hello,
Is it possible to replace more words on the same line at once?

I want to do the following thing:

Find one of these words: ft,feat,vs, Versus
and replace it with: ;

Re: RegExp Find & Replace 2.2.2 - with 50 presets [MM2+3]

Posted: Tue Sep 02, 2008 4:45 pm
by ZvezdanD
djo4ever wrote:Is it possible to replace more words on the same line at once?
Yes, it is.
djo4ever wrote:Find one of these words: ft,feat,vs, Versus
and replace it with: ;
Did you tried the suggestion described at http://www.mediamonkey.com/forum/viewto ... 20#p163520?

Re: RegExp Find & Replace 2.2.2 - with 50 presets [MM2+3]

Posted: Wed Sep 10, 2008 12:53 am
by barkoz
ZvezdanD wrote
Glad you found your way to do this. However, I think this is not the best approach for such thing because it would remove all occurrences of specified characters, even if they are not a part of timing marks - "[", "]", ":" and digits from "0" till "9". This is because square brackets are reserved characters in RegExp and they are used for specifying character classes. If you want to specify square brackets as plain characters you should put backslash in the front of them - \[ and \].
Thank's mate,I hadn't realised that, is there anything this script can't do besides the dishes? :D :D :D

Re: RegExp Find & Replace 2.2.2 - with 50 presets [MM2+3]

Posted: Wed Sep 10, 2008 9:02 am
by gege
barkoz wrote:Thank's mate,I hadn't realised that, is there anything this script can't do besides the dishes? :D :D :D
I'm almost sure it can't do the laundry too... but who knows :roll:

Re: RegExp Find & Replace 2.2.2 - with 50 presets [MM2+3]

Posted: Mon Sep 22, 2008 1:52 pm
by MCSmarties
Wow this script is powerful! Many thanks!

I have mainly been using it to work on lyrics and noticed a small nit-pick:

The preset "Uppercase the first letter of each line of the Lyrics" is not ideal.
Currently, it uppercases the first character but sets everything else in lower case!
Anything that was capitalized before is now lower case, including for examples place
names and pronouns ("i am" vs "I am").

An easy fix is to change the replace with field:

Code: Select all

UCase("$1") & LCase("$2")
should be replaced with

Code: Select all

UCase("$1") & "$2"
Of course, this assumes that the ONLY capitalization problem with the lyrics was the first letter of each line...

Another alternative I found is a simple preset to always capitalize the pronoun "I", as follows:

Code: Select all

Uppercase "i" in the Lyrics
Find what: \bi\b
Into: Lyrics
Replace with:I
Match case: checked
That got me thinking, would it be possible to make a preset that would replace all kinds of words with others?
Like "cos", "cuz" with "cause" (a pet peeve of mine), or add apostrophes where missing (im, ill, dont, wont -> I'm, I'll, don't, won't)

Your script uses an extremely powerful algorithm, I think it would be great to incorporate it into a dedicated
"lyrics cleanup script" with user-defined replacements. Combined with das Monkey's amazing "Lyricator" script,
it would make adding lyrics a breeze indeed!

Re: RegExp Find & Replace 2.2.2 - with 50 presets [MM2+3]

Posted: Tue Sep 23, 2008 8:00 am
by ZvezdanD
MCSmarties wrote:The preset "Uppercase the first letter of each line of the Lyrics" is not ideal.
Currently, it uppercases the first character but sets everything else in lower case!
Yes, I am aware about the English word "I" (http://www.mediamonkey.com/forum/viewto ... 44#p163244), and there is also a problem with personal names which should have first character uppercased.
MCSmarties wrote:Of course, this assumes that the ONLY capitalization problem with the lyrics was the first letter of each line...
Well, this is just one more problem for such implementation. What if someone has a lyrics with all characters in uppercase? How about languages where "I" should not be uppercased? Believe it or not, in my language the word "I" has a meaning of "and" in English and it should be lowercased when it is in sentence.

Anyway, I am thinking to introduce one more preset for the next version of this script which would be same as mentioned preset, except it would uppercase the word "I" and maybe it would have a rather limited list of English personal names (of course, this list would be user-customizable).
MCSmarties wrote:would it be possible to make a preset that would replace all kinds of words with others?
Like "cos", "cuz" with "cause" (a pet peeve of mine), or add apostrophes where missing (im, ill, dont, wont -> I'm, I'll, don't, won't)
Of course it is possible. There are already included some presets which are doing similar thing, even within only one step. Just take a look at the preset "Fix common words (featuring, presents, versus)" or "Remove diacritical marks from the Title" - with a single preset you could replace many characters or words to another characters or words: Feat, feat, Feat., feat., Featuring, featuring, Features, features, Ft, ft, Ft. are all converted to ft., then Presents, Presenting ... to pres. and Versus, Vs ... to vs.. It is all possible with a help of the custom VB function MapArray.

Here are settings for your example:
Find what:

Code: Select all

\b(?:(cos|cuz)|([Ii]m)|([Ii]ll)|(dont)|(wont))\b
Replace with:

Code: Select all

MapArray(Array("$1", "cause", "$2", "I'm", "$3", "I'll", "$4", "don't", "$5", "won't"))

Re: RegExp Find & Replace 2.2.2 - with 50 presets [MM2+3]

Posted: Wed Oct 15, 2008 9:57 am
by xabaras
I apologize if this question has been answered already but I was curious if there would be a way to use the 'fix featured' routine and modify it so that I could make the Title of the song have featured artist instead of the artist.. example:

From
------
Artist: 112 featuring Lil'z
Title: Anywhere

To
----
Artist: 112
Title: Anywhere (feat. Lil'z)

Any help would be great... you have a get product I am just really lame when it comes to coding

Re: RegExp Find & Replace 2.2.2 - with 50 presets [MM2+3]

Posted: Wed Oct 15, 2008 10:55 am
by ZvezdanD
xabaras wrote:if there would be a way to use the 'fix featured' routine and modify it so that I could make the Title of the song have featured artist instead of the artist..
Have you tried a suggestion described at http://www.mediamonkey.com/forum/viewto ... 36#p154236?

Re: RegExp Find & Replace 2.2.2 - with 50 presets [MM2+3]

Posted: Thu Oct 16, 2008 1:36 pm
by Owyn
Thanks for the script. Should have got it a while ago.