INTERACT FORUM

Please login or register.

Login with username, password and session length
Advanced search  
Pages: [1]   Go Down

Author Topic: please help with regex  (Read 1235 times)

HaWi

  • Citizen of the Universe
  • *****
  • Posts: 946
please help with regex
« on: May 04, 2022, 01:50:54 pm »

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
Logged
rPi5/8GB, Debian 12 Bookworm on SSD | JRMark (33.0.37 64 bit): 2784
MacBookPro (2013), 2.6 GHz Quad-Core Intel Core i7, MacOS 11.7.17 | JRMark (33.0.41 64 bit): 3826
Mac Studio M2 Max, 64GB, 1TB SSD, macOS Sequoia 15.1.1 | JRMark (33.0.41 64 bit): 9056
Docker Container (shiomax) DS1819+ | JRMark (33.0.37 64 bit): 1431
JRemote 3.43
MO 4Media 1.5.7 | Marantz SR7007 (RSL 5.1) HDMI to MacBookPro

zybex

  • MC Beta Team
  • Citizen of the Universe
  • *****
  • Posts: 2618
Re: please help with regex
« Reply #1 on: May 04, 2022, 03:11:25 pm »

Assuming [Soloists] contains only 1 item (ie, not a list):
Code: [Select]
regex([Soloists],/#-\s*(.+)#/,1)
If it's a list this should work:
Code: [Select]
regex([Soloists],/#-\s*([^;$]+)#/,-2)
Logged

blgentry

  • Regular Member
  • Citizen of the Universe
  • *****
  • Posts: 8014
Re: please help with regex
« Reply #2 on: May 05, 2022, 08:42:14 am »

I have officially been unseated as the Regex Champ of JRiver.

Long live Zybex!

Brian.
Logged

HaWi

  • Citizen of the Universe
  • *****
  • Posts: 946
Re: please help with regex
« Reply #3 on: May 05, 2022, 09:42:16 am »

Assuming [Soloists] contains only 1 item (ie, not a list):
Code: [Select]
regex([Soloists],/#-\s*(.+)#/,1)
If it's a list this should work:
Code: [Select]
regex([Soloists],/#-\s*([^;$]+)#/,-2)

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!
Logged
rPi5/8GB, Debian 12 Bookworm on SSD | JRMark (33.0.37 64 bit): 2784
MacBookPro (2013), 2.6 GHz Quad-Core Intel Core i7, MacOS 11.7.17 | JRMark (33.0.41 64 bit): 3826
Mac Studio M2 Max, 64GB, 1TB SSD, macOS Sequoia 15.1.1 | JRMark (33.0.41 64 bit): 9056
Docker Container (shiomax) DS1819+ | JRMark (33.0.37 64 bit): 1431
JRemote 3.43
MO 4Media 1.5.7 | Marantz SR7007 (RSL 5.1) HDMI to MacBookPro

zybex

  • MC Beta Team
  • Citizen of the Universe
  • *****
  • Posts: 2618
Re: please help with regex
« Reply #4 on: May 05, 2022, 10:44:24 am »

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: [Select]
regex([_tmp],/#[-–]\s*([^;$]+)#/,-2)
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: [Select]
regex([_tmp],/# [-–] ([^;$]+)#/,-2)
Logged

HaWi

  • Citizen of the Universe
  • *****
  • Posts: 946
Re: please help with regex
« Reply #5 on: May 05, 2022, 12:10:08 pm »

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: [Select]
regex([_tmp],/#[-–]\s*([^;$]+)#/,-2)
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: [Select]
regex([_tmp],/# [-–] ([^;$]+)#/,-2)

Wow, this is amazing. I am bowing in front of the master. Thank you so much, Zybex!
EDIT: naturally, needed to replace the [_tmp] with [Soloists] (you are testing me  ;D ) and it works as a charm. Thanks again so much, Zybex!
Logged
rPi5/8GB, Debian 12 Bookworm on SSD | JRMark (33.0.37 64 bit): 2784
MacBookPro (2013), 2.6 GHz Quad-Core Intel Core i7, MacOS 11.7.17 | JRMark (33.0.41 64 bit): 3826
Mac Studio M2 Max, 64GB, 1TB SSD, macOS Sequoia 15.1.1 | JRMark (33.0.41 64 bit): 9056
Docker Container (shiomax) DS1819+ | JRMark (33.0.37 64 bit): 1431
JRemote 3.43
MO 4Media 1.5.7 | Marantz SR7007 (RSL 5.1) HDMI to MacBookPro

zybex

  • MC Beta Team
  • Citizen of the Universe
  • *****
  • Posts: 2618
Re: please help with regex
« Reply #6 on: May 06, 2022, 02:30:03 am »

Wow, this is amazing. I am bowing in front of the master. Thank you so much, Zybex!
EDIT: naturally, needed to replace the [_tmp] with [Soloists] (you are testing me  ;D ) and it works as a charm. Thanks again so much, Zybex!

Oops ::)
That's from testing with Zelda using a temp field, I forgot to edit it after pasting here.

You're welcome.
Logged

HaWi

  • Citizen of the Universe
  • *****
  • Posts: 946
Re: please help with regex
« Reply #7 on: May 06, 2022, 09:50:26 am »

Oops ::)
That's from testing with Zelda using a temp field, I forgot to edit it after pasting here.

You're welcome.
For a split second there I thought it was some high level regex magic  ::) but then it clicked that it was a test field.
I really appreciate your help
Logged
rPi5/8GB, Debian 12 Bookworm on SSD | JRMark (33.0.37 64 bit): 2784
MacBookPro (2013), 2.6 GHz Quad-Core Intel Core i7, MacOS 11.7.17 | JRMark (33.0.41 64 bit): 3826
Mac Studio M2 Max, 64GB, 1TB SSD, macOS Sequoia 15.1.1 | JRMark (33.0.41 64 bit): 9056
Docker Container (shiomax) DS1819+ | JRMark (33.0.37 64 bit): 1431
JRemote 3.43
MO 4Media 1.5.7 | Marantz SR7007 (RSL 5.1) HDMI to MacBookPro
Pages: [1]   Go Up