Page 96 of 108

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

Posted: Fri Oct 20, 2017 10:21 pm
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.

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

Posted: Mon Oct 23, 2017 10:33 pm
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"), "$&")

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

Posted: Tue Oct 24, 2017 4:41 am
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.).

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

Posted: Tue Oct 24, 2017 9:02 am
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.

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

Posted: Tue Oct 24, 2017 9:07 am
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.

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

Posted: Tue Oct 24, 2017 7:04 pm
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)

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

Posted: Sat Nov 11, 2017 4:26 am
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)?

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

Posted: Sat Nov 11, 2017 4:26 pm
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.

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

Posted: Wed Nov 15, 2017 2:26 pm
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?

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

Posted: Wed Nov 15, 2017 5:14 pm
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

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

Posted: Wed Nov 15, 2017 7:25 pm
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!

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

Posted: Wed Nov 15, 2017 8:49 pm
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.

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

Posted: Thu Nov 16, 2017 4:44 am
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.

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

Posted: Sun Nov 26, 2017 8:55 pm
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

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

Posted: Mon Nov 27, 2017 1:52 am
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".