More > JRiver Media Center 29 for Mac
please help with regex
HaWi:
My [Soloists] field contains <instrument><space><–><space><soloist name> example: Violin – Gil Shaham
Could someone help me with a regex expression to extract the <soloist name> from this, please?
Many thanks for any help!
Hans
zybex:
Assuming [Soloists] contains only 1 item (ie, not a list):
--- Code: ---regex([Soloists],/#-\s*(.+)#/,1)
--- End code ---
If it's a list this should work:
--- Code: ---regex([Soloists],/#-\s*([^;$]+)#/,-2)
--- End code ---
blgentry:
I have officially been unseated as the Regex Champ of JRiver.
Long live Zybex!
Brian.
HaWi:
--- Quote from: zybex on May 04, 2022, 03:11:25 pm ---Assuming [Soloists] contains only 1 item (ie, not a list):
--- Code: ---regex([Soloists],/#-\s*(.+)#/,1)
--- End code ---
If it's a list this should work:
--- Code: ---regex([Soloists],/#-\s*([^;$]+)#/,-2)
--- End code ---
--- End quote ---
Thank you so much Zybex! I'll try this out right away.
EDIT:
I tried both versions but unfortunately got a blank in both, wiith single Soloist and with lists. Could this be because the - is an em-dash (–), like <Option>-?
EDIT2:
In [Soloists], I am replacing all regular dashes (hyphened names) with spaces and all em-dashes with regular dashes. Preliminary evidence suggests that will yield the desired results with the regex expressions. Gonna take a while, MC is grinding through >15K tracks right now for the Classical part. Will do the non-classical part if this works out as expected.
Many thanks again, Zybex!
zybex:
Well yesterday I was looking at your dash and thinking "is he using em-dash? Oh well, who cares" ;D
Here's one that works with both - take care to copy/paste it, that's an em-dash in there:
--- Code: ---regex([_tmp],/#[-–]\s*([^;$]+)#/,-2)
--- End code ---
There's a standard regex class that would capture all kinds of dashes but MC doesn't seem to support named classes. It would be so:
regex([_tmp],/#\p{Pd}\s*([^;$]+)#/,-2)
EDIT: If you want to allow hyphened names and only split on "space+[em]dash+space", you can use this one:
--- Code: ---regex([_tmp],/# [-–] ([^;$]+)#/,-2)
--- End code ---
Navigation
[0] Message Index
[#] Next page
Go to full version