MB ID’s are UUIDs and have a fixed length.
Due to some (previously reported) weird issues I have had in the past that are no longer occurring on new files, many of my files have the last character repeated in one or more custom fields, leading to sometimes up to 45 characters in the MB IDs. When I tell Jaikoz to try and fix these albums, it won’t do much because it thinks there’s already an MB ID.
I propose that it would make sense to validate the field prior to using it , and try stripping characters (first leading, then trailing) to see if that produces a valid MBID in the case that it is greater than 33 without dashes or 36 with.
This perl regex would do both:
/[\\da-f]{8}-[\\da-f]{4}-[\\da-f]{4}-[\\da-f]{4}-[\\da-f]{12}/i
The i modifier is case insensitivity just in case some other tool used uppercase, and we wouldn’t want to fail to validate that. Adding A-F to each character class would have the same effect but look less clean.
When using this to fix the aftermath of the bug I had encountered, looking up the mbid returns a valid result, and I would then need to update data from that existing mbid in order to fix the other fields (eg. release type “Albummmmmm”, mb artist id and unique id.)
I wrote a perl script to do this for my library but it would be nice if the replacement functionality had something similar or at least find/replace had regexp support and allowed you to specify your own column name.