RegExp Find & Replace 4.3 w/ 253 presets (2011-07-06) [MM2+]

Download and get help for different MediaMonkey for Windows 4 Addons.

Moderators: Peke, Gurus

TRegina
Posts: 10
Joined: Thu Oct 27, 2016 8:52 pm

Re: RegExp Find & Replace 4.3 w/ 253 presets (2011-07-06) [M

Post by TRegina »

Hello,

Is there some expression I can insert into the Capitalize preset that will keep Irish names that begin with "McC****" intact and not turn them into "Mcc***"?

Thanks.
mhendu
Posts: 100
Joined: Thu Jan 12, 2006 11:18 am

Re: RegExp Find & Replace 4.3 w/ 253 presets (2011-07-06) [M

Post by mhendu »

I use Custom5 to store the AcoustID from Musicbrainz, and every so often I get a new version of the same track - I'd like to copy the genre and date from the older file to the newer file, without having to dig through my database to find the duplicates. I'm using a modified version of one of the presets of this script to try to source the year and copy that over but I'm no SQL or regular expressions expert so I couldn't figure out how to copy the entire date (in those cases where the database has mm/dd/yyyy), and currently my query below returns eight characters for the year instead of just the expected four (e.g., 19650000). Any help to fix these issues would be appreciated - my workaround is to copy the year to another field for now, then to copy that over less the four ending characters, but would prefer to just copy the date directly.

IfNull(SQLQuery("SELECT Year AS SortField FROM Songs WHERE Custom5 = '" & Replace(oSongData.Custom5, "'", "''") & "' AND Year <> '' GROUP BY Year ORDER BY SortField DESC"), "$&")
MMFrLife
Posts: 2894
Joined: Fri Oct 26, 2012 9:04 pm
Location: MM Forum

Re: RegExp Find & Replace 4.3 w/ 253 presets (2011-07-06) [M

Post by MMFrLife »

TRegina wrote:Is there some expression I can insert into the Capitalize preset that will keep Irish names that begin with "McC****" intact and not turn them into "Mcc****?
I'm not sure about an expression, as the letters and positions may vary from name to name. You can just enter some of the Irish names that you
are concerned with to the "other" exceptions field (in whole; McCullers, etc.).
Last edited by MMFrLife on Tue Oct 24, 2017 9:04 am, edited 5 times in total.
MM user since 2003 (lifetime lic. 2012) "Trying to imagine life without music gives me a headache"
Top 2 scripts: RegExp Find & Replace (e.v.) and Magic Nodes (e.v.) ZvezdanD's scripts site
Please take a moment to read the bottom of the linked page to support the one and only - ZvezdanD! (the "originator" since 2006).
MMW 4.1.31.1919; 5.0.4.2690 || back it up...frequently!
|| software for power users: "Q-Dir" (free alt. to explorer) and file/folder renamer: "ReNamer" (den4b)
"The absurd is the essential concept and the first truth"
😜
ZvezdanD
Posts: 3257
Joined: Thu Jun 08, 2006 7:40 pm

Re: RegExp Find & Replace 4.3 w/ 253 presets (2011-07-06) [M

Post by ZvezdanD »

mhendu wrote:I'm using a modified version of one of the presets of this script to try to source the year and copy that over but I'm no SQL or regular expressions expert
If you are using a modified version, then I suppose you know at least VBScript. You could use Left(..., 4) to get the leftmost 4 characters of any string.
Magic Nodes 4.3.3 / 5.2 RegExp Find & Replace 4.4.9 / 5.2  Invert Selection/Select None 1.5.1  Export/Create Playlists for Child Nodes 4.1.1 / 5.4.1  Expand Child Nodes/Expand All 1.1.2  Event Logger 2.7  Filtered Statistics Report 1.6  Track Redirection & Synchronization 3.4.2  Restore/Synchronize Database 3.1.8 / 4.0.1  Find Currently Playing Track 1.3.2  Queue List 1.2.1  Add to Library on Play 1.0.1  Tree Report for Child Nodes 1.1.1  Update Location of Files in Database 1.4.5 / 2.3  Inherit Child Playlists 1.0.3  Add Currently Playing/Selected Track(s) to Playlist 1.2
ZvezdanD
Posts: 3257
Joined: Thu Jun 08, 2006 7:40 pm

Re: RegExp Find & Replace 4.3 w/ 253 presets (2011-07-06) [M

Post by ZvezdanD »

MMFrLife wrote:
TRegina wrote:Is there some expression I can insert into the Capitalize preset that will keep Irish names that begin with "McC****" intact and not turn them into "Mcc****?
I'm not sure about an expression, as the letters and positions may vary from name to name. You can just enter some of the Irish names that you
are concerned with to the "other" exceptions field (in whole; McCullers, etc.).
Are you finished with the editing of that post? :)

If you tried the preset updated in v5.1, you would know that it has Prefixes tag with Mc and O' already predefined.
Magic Nodes 4.3.3 / 5.2 RegExp Find & Replace 4.4.9 / 5.2  Invert Selection/Select None 1.5.1  Export/Create Playlists for Child Nodes 4.1.1 / 5.4.1  Expand Child Nodes/Expand All 1.1.2  Event Logger 2.7  Filtered Statistics Report 1.6  Track Redirection & Synchronization 3.4.2  Restore/Synchronize Database 3.1.8 / 4.0.1  Find Currently Playing Track 1.3.2  Queue List 1.2.1  Add to Library on Play 1.0.1  Tree Report for Child Nodes 1.1.1  Update Location of Files in Database 1.4.5 / 2.3  Inherit Child Playlists 1.0.3  Add Currently Playing/Selected Track(s) to Playlist 1.2
mhendu
Posts: 100
Joined: Thu Jan 12, 2006 11:18 am

Re: RegExp Find & Replace 4.3 w/ 253 presets (2011-07-06) [M

Post by mhendu »

ZvezdanD wrote:
mhendu wrote:I'm using a modified version of one of the presets of this script to try to source the year and copy that over but I'm no SQL or regular expressions expert
If you are using a modified version, then I suppose you know at least VBScript. You could use Left(..., 4) to get the leftmost 4 characters of any string.
Thanks. I have no idea what I'm doing but I managed to figure that out. Just added Left(...,4) around the VBScript that I'd posted in my earlier post and it worked perfectly. Thank you.

I've also been adding the Musicbrainz Work ID to my tracks and created a code to look this up from Custom4 and pull in the oldest year associated with a given Work ID. Since many of my tracks have a blank Work ID I had to add in a filter to only show those tracks where Custom4 was not empty. This is helpful to get the composition year for classical music from an existing track in my library of that same composition.

LEFT(IfNull(SQLQuery("SELECT Year AS SortField FROM Songs WHERE Custom4 = '" & Replace(oSongData.Custom4, "'", "''") & "' AND Year > 0 AND Custom4 <> '' GROUP BY Year ORDER BY SortField"), "$&"),4)
MMFrLife
Posts: 2894
Joined: Fri Oct 26, 2012 9:04 pm
Location: MM Forum

Re: RegExp Find & Replace 4.3 w/ 253 presets (2011-07-06) [M

Post by MMFrLife »

I'm using "Auto-increment Track number with specified starting value and leading zero(es)...". I have it set from Entire to End of Into field.
Is there a way to insert a space before it, using that same preset (without batching something to it)?
MM user since 2003 (lifetime lic. 2012) "Trying to imagine life without music gives me a headache"
Top 2 scripts: RegExp Find & Replace (e.v.) and Magic Nodes (e.v.) ZvezdanD's scripts site
Please take a moment to read the bottom of the linked page to support the one and only - ZvezdanD! (the "originator" since 2006).
MMW 4.1.31.1919; 5.0.4.2690 || back it up...frequently!
|| software for power users: "Q-Dir" (free alt. to explorer) and file/folder renamer: "ReNamer" (den4b)
"The absurd is the essential concept and the first truth"
😜
ZvezdanD
Posts: 3257
Joined: Thu Jun 08, 2006 7:40 pm

Re: RegExp Find & Replace 4.3 w/ 253 presets (2011-07-06) [M

Post by ZvezdanD »

MMFrLife wrote:Is there a way to insert a space before it, using that same preset (without batching something to it)?
Add " " & at the begin of the Replace with string.
Magic Nodes 4.3.3 / 5.2 RegExp Find & Replace 4.4.9 / 5.2  Invert Selection/Select None 1.5.1  Export/Create Playlists for Child Nodes 4.1.1 / 5.4.1  Expand Child Nodes/Expand All 1.1.2  Event Logger 2.7  Filtered Statistics Report 1.6  Track Redirection & Synchronization 3.4.2  Restore/Synchronize Database 3.1.8 / 4.0.1  Find Currently Playing Track 1.3.2  Queue List 1.2.1  Add to Library on Play 1.0.1  Tree Report for Child Nodes 1.1.1  Update Location of Files in Database 1.4.5 / 2.3  Inherit Child Playlists 1.0.3  Add Currently Playing/Selected Track(s) to Playlist 1.2
MMFrLife
Posts: 2894
Joined: Fri Oct 26, 2012 9:04 pm
Location: MM Forum

Re: RegExp Find & Replace 4.3 w/ 253 presets (2011-07-06) [M

Post by MMFrLife »

Thanks, those are the elements I was trying to find/insert somewhere. I just couldn't get them exact :( , but now :D .

Similar to the above example:

If I use "Copy <From Field> to <Into Field>..." and set Entire to Begin, how would I insert
a space between the beg. string and the original string?
MM user since 2003 (lifetime lic. 2012) "Trying to imagine life without music gives me a headache"
Top 2 scripts: RegExp Find & Replace (e.v.) and Magic Nodes (e.v.) ZvezdanD's scripts site
Please take a moment to read the bottom of the linked page to support the one and only - ZvezdanD! (the "originator" since 2006).
MMW 4.1.31.1919; 5.0.4.2690 || back it up...frequently!
|| software for power users: "Q-Dir" (free alt. to explorer) and file/folder renamer: "ReNamer" (den4b)
"The absurd is the essential concept and the first truth"
😜
ZvezdanD
Posts: 3257
Joined: Thu Jun 08, 2006 7:40 pm

Re: RegExp Find & Replace 4.3 w/ 253 presets (2011-07-06) [M

Post by ZvezdanD »

MMFrLife wrote:If I use "Copy <From Field> to <Into Field>..." and set Entire to Begin, how would I insert
a space between the beg. string and the original string?
Which version of the preset are you using? The latest one has tags that allow appending to the begin/end with specified separator without need to modify Find what or Replace with strings directly.

Image
Magic Nodes 4.3.3 / 5.2 RegExp Find & Replace 4.4.9 / 5.2  Invert Selection/Select None 1.5.1  Export/Create Playlists for Child Nodes 4.1.1 / 5.4.1  Expand Child Nodes/Expand All 1.1.2  Event Logger 2.7  Filtered Statistics Report 1.6  Track Redirection & Synchronization 3.4.2  Restore/Synchronize Database 3.1.8 / 4.0.1  Find Currently Playing Track 1.3.2  Queue List 1.2.1  Add to Library on Play 1.0.1  Tree Report for Child Nodes 1.1.1  Update Location of Files in Database 1.4.5 / 2.3  Inherit Child Playlists 1.0.3  Add Currently Playing/Selected Track(s) to Playlist 1.2
MMFrLife
Posts: 2894
Joined: Fri Oct 26, 2012 9:04 pm
Location: MM Forum

Re: RegExp Find & Replace 4.3 w/ 253 presets (2011-07-06) [M

Post by MMFrLife »

Yes, I figured out the problem. I used that preset from an older one before many of the parameters were consolidated".
Although, sometimes I just forget to use the tuner. When I first learned it, I use to do almost everything directly
and just kept doing it that way. I'm better now, but that habit still haunts me on occasion.

Thanks!
MM user since 2003 (lifetime lic. 2012) "Trying to imagine life without music gives me a headache"
Top 2 scripts: RegExp Find & Replace (e.v.) and Magic Nodes (e.v.) ZvezdanD's scripts site
Please take a moment to read the bottom of the linked page to support the one and only - ZvezdanD! (the "originator" since 2006).
MMW 4.1.31.1919; 5.0.4.2690 || back it up...frequently!
|| software for power users: "Q-Dir" (free alt. to explorer) and file/folder renamer: "ReNamer" (den4b)
"The absurd is the essential concept and the first truth"
😜
MMFrLife
Posts: 2894
Joined: Fri Oct 26, 2012 9:04 pm
Location: MM Forum

Re: RegExp Find & Replace 4.3 w/ 253 presets (2011-07-06) [M

Post by MMFrLife »

Ok, so I updated to the proper one (with the exact same tuner display as shown above) and noticed that when I
use Append - to begin it does it to the end, and Append - to the end puts it at the begin.
If I use Assign, then change Entire to begin, it basically works but no space.

Is the code accidentally flipped or something. I tried it on different non-numerical fields and got the same flipped results.
MM user since 2003 (lifetime lic. 2012) "Trying to imagine life without music gives me a headache"
Top 2 scripts: RegExp Find & Replace (e.v.) and Magic Nodes (e.v.) ZvezdanD's scripts site
Please take a moment to read the bottom of the linked page to support the one and only - ZvezdanD! (the "originator" since 2006).
MMW 4.1.31.1919; 5.0.4.2690 || back it up...frequently!
|| software for power users: "Q-Dir" (free alt. to explorer) and file/folder renamer: "ReNamer" (den4b)
"The absurd is the essential concept and the first truth"
😜
ZvezdanD
Posts: 3257
Joined: Thu Jun 08, 2006 7:40 pm

Re: RegExp Find & Replace 4.3 w/ 253 presets (2011-07-06) [M

Post by ZvezdanD »

You are right, it was flipped. Thanks for the report. Here is the fixed Replace with string:
<If Caption="Assign to the field" Value=1 ID=1><From Field><Else Caption="Append to:"><If Caption="the begin of field" Value=1 ID=2><From Field><Else Caption="the end of field">"$_"<End If> & IIf(Len("$_") > 0 And Len(<From Field>) > 0, "<String Caption="Separator" Value=" - " ID=3>", "") & <If ID:2>"$_"<Else><From Field><End If><End If>

You don't need to (actually, you shouldn't) use the Entire/Begin button with the mentioned preset. That button is an extension of the Full button from the freely available version with added some new options. It doesn't represent any preset's parameter/option and its state is not saved with the preset. It is just a short way to insert to/replace Find what or Replace with string with some predefined pattern, e.g. with the Entire item you will get "^.*" which is the Regex replacement for the full content of the field. The mentioned preset has that thing already defined in the Find what and Replace with strings, it is enough to customize it using the Tune dialog box.

By the way, it is always recommended that you use the presets supplied with the latest version of the add-on using a guide mentioned in the Installation section, because many preset could be updated/improved, which is a fact that I mentioned in the What Is New section.
Magic Nodes 4.3.3 / 5.2 RegExp Find & Replace 4.4.9 / 5.2  Invert Selection/Select None 1.5.1  Export/Create Playlists for Child Nodes 4.1.1 / 5.4.1  Expand Child Nodes/Expand All 1.1.2  Event Logger 2.7  Filtered Statistics Report 1.6  Track Redirection & Synchronization 3.4.2  Restore/Synchronize Database 3.1.8 / 4.0.1  Find Currently Playing Track 1.3.2  Queue List 1.2.1  Add to Library on Play 1.0.1  Tree Report for Child Nodes 1.1.1  Update Location of Files in Database 1.4.5 / 2.3  Inherit Child Playlists 1.0.3  Add Currently Playing/Selected Track(s) to Playlist 1.2
Spix
Posts: 9
Joined: Tue Mar 21, 2017 3:49 pm

Re: RegExp Find & Replace 4.3 w/ 253 presets (2011-07-06) [M

Post by Spix »

Hi,

I have a a song with title "myTitle - myBand" in my MM database and want to use regular expressions to move the part "myBand" to the artist field.

So I tried:
Find what: ".* - .*" | Into: Artist | Regular expression 1: marked | without "Full" and "Find whole words only"
Original: "Unknown Artist"

Replace with: "\2" or "$2" | From: Title | Regular expression 2: marked | without "Full", "VBScript", "Match case", "Backward search direction"
Replacement: "myTitle - myBand"
Result: "Unknown Artist"


I expected the Result: "myBand" but get "Unknown Artist" !

In general I'm familiar with regular expressions, so I'm very interested to find my bug!
Does anybody have an idea what I'm doing wrong?

Best regards
Spix
ZvezdanD
Posts: 3257
Joined: Thu Jun 08, 2006 7:40 pm

Re: RegExp Find & Replace 4.3 w/ 253 presets (2011-07-06) [M

Post by ZvezdanD »

You don't have any capture group in the Find what regular expression, so $2 cannot replace anything. Also, Regular expression 2 should not be turned on in your case.

The freely available version of the add-on doesn't have a single predefined preset to move a part of the source field to the destination field at once. However, there is several predefined presets that could be used to copy the begin of the source field before the " - " to the destination, e.g. "Assign the begin of <From Field> before "" - "" to <Into Field>", or "Assign the begin of <From Field> before specified string to <Into Field>". After that you could use another preset to remove that begin from the source field, e.g. "Remove the begin of <Into Field> before (and including) "" - """ or "Remove the begin of <Into Field> before (and including) specified string".
Magic Nodes 4.3.3 / 5.2 RegExp Find & Replace 4.4.9 / 5.2  Invert Selection/Select None 1.5.1  Export/Create Playlists for Child Nodes 4.1.1 / 5.4.1  Expand Child Nodes/Expand All 1.1.2  Event Logger 2.7  Filtered Statistics Report 1.6  Track Redirection & Synchronization 3.4.2  Restore/Synchronize Database 3.1.8 / 4.0.1  Find Currently Playing Track 1.3.2  Queue List 1.2.1  Add to Library on Play 1.0.1  Tree Report for Child Nodes 1.1.1  Update Location of Files in Database 1.4.5 / 2.3  Inherit Child Playlists 1.0.3  Add Currently Playing/Selected Track(s) to Playlist 1.2
Post Reply