Thanks for your question, and for including the details on your mapping rule; very helpful.
I am happy that I have not been entirely replaced by AI chatbots. Here is a template that will give you better results:
Name: Instrument
Data Source: -- Template (see below) --
Meta/template: [+name_only,extract( '/(.*)_(.*)/' )+]([+matches:2+])
Existing text: Replace
Format: Native
Option: Text
Delete NULL Values: checked
Status: active
You must set the Data Source to -- Template (see below) -- so MLA will process the template. The template provided starts with the name_only data source (the name portion of the file name); more reliable than the WordPress post_title data source. The extract( '/(.*)_(.*)/' ) format/option suffix divides the name into two subpatterns: 1. title and 2. instrument, discarding the underscore that separates them. The extract suffix puts the subpatterns into an array of matches. The ([+matches:2+]) data source returns the second subpattern content, if present.
You can add a second rule to save the title portion of the file name by changing the last part of the template to ([+matches:1+]), the first subpattern.
You can find more information about MLA’s regular expression features in the “Regular Expression Features” section of the Settings/Media Library Assistant Documentation tab. Note, however, that the “named subpatterns” outlined in the documentation do not currently work in mapping rules. That is an MLA defect I will correct in my next update, and I am glad this topic helped me uncover the problem.
I hope that gives you a solution for your application. I am marking this topic resolved, but please update it if you have any problems or further questions regarding the above suggestions. Thanks for your interest in the plugin.
Hi David
Thank you very very very much for your answer. Your solution works perfectly. It puts an end to my days‑long search. I finally have time again to eat and sleep.
Your plugin is fantastic.
Kind regards
Geert Willemarck
I have released MLA v3.35, that contains the fix for the regular expression “named subpatterns” issue uncovered during my work on this topic.
Thanks for your kind words regarding MLA and for your interest in the plugin.