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

Post a reply

Visual Confirmation

To prevent automated access and spam, you are required to confirm that you are human. Please place a check mark next to all images of monkeys or apes. If you cannot see any images, please contact the Board Administrator.

Smilies
:D :) :( :o :-? 8) :lol: :x :P :oops: :cry: :evil: :roll: :wink:
BBCode is ON
[img] is ON
[flash] is OFF
[url] is ON
Smilies are ON
Topic review
   

Expand view Topic review: RegExp Find & Replace 4.3 w/ 253 presets (2011-07-06) [MM2+]

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

Post by ZvezdanD » Thu Nov 16, 2017 4:44 am

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.

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

Post by MMFrLife » Wed Nov 15, 2017 8:49 pm

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.

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

Post by MMFrLife » Wed Nov 15, 2017 7:25 pm

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!

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

Post by ZvezdanD » Wed Nov 15, 2017 5:14 pm

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

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

Post by MMFrLife » Wed Nov 15, 2017 2:26 pm

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?

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

Post by ZvezdanD » Sat Nov 11, 2017 4:26 pm

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.

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

Post by MMFrLife » Sat Nov 11, 2017 4:26 am

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

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

Post by mhendu » Tue Oct 24, 2017 7:04 pm

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)

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

Post by ZvezdanD » Tue Oct 24, 2017 9:07 am

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.

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

Post by ZvezdanD » Tue Oct 24, 2017 9:02 am

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.

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

Post by MMFrLife » Tue Oct 24, 2017 4:41 am

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

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

Post by mhendu » Mon Oct 23, 2017 10:33 pm

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"), "$&")

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

Post by TRegina » Fri Oct 20, 2017 10:21 pm

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.

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

Post by ZvezdanD » Wed Oct 18, 2017 7:00 am

Sorry, RFR could be applied only on files that are selected (for Replace actions) or visible (for Keep/Select actions) in the main filelist. So, if you want to apply it on all files, you need to have selected Entire Library node (or any other node that shows all files from the library). Actually, there is one exception to this rule: Replace in currently playing file.

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

Post by MMFrLife » Wed Oct 18, 2017 5:24 am

Thanks, I already have the MM toolbar button for selecting. I'm not much of a hotkey person.
I was mainly trying to figure out a way to batch a 'selecting preset' (which isn't possible without already
having selected something) with a 'word find' preset, so I don't have to select Entire Library whenever I look for a word.

Top

cron