INTERACT FORUM

Please login or register.

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

Author Topic: Manage links: how to replace spaces by a dash?  (Read 938 times)

MarkCoutinho

  • Regular Member
  • Citizen of the Universe
  • *****
  • Posts: 676
Manage links: how to replace spaces by a dash?
« on: August 09, 2021, 02:31:28 am »

Hi everyone,

I'm trying to make a link in MC to search for songfacts about a song. I'm getting pretty close with this:
https:////www.songfacts.com//facts//regex([Artist]//[Name], /#^(.+?)(?: [[(]extended\b[^)\]]*[)\]])?$#/, 1)
(I don't want the query to contain 'extended version' - hence the exclusion of that word)

However the output is this: https://www.songfacts.com/facts/middle%20of%20the%20road/soley%20soley/
And it should be: https://www.songfacts.com/facts/middle-of-the-road/soley-soley/

Could someone tell me what to do to replace the spaces between the words by the - sign?

Thanks!
Logged
Mark Coutinho
Dutch Top 40 collector of lyrics, sleeves and bios

zybex

  • MC Beta Team
  • Citizen of the Universe
  • *****
  • Posts: 2674
Re: Manage links: how to replace spaces by a dash?
« Reply #1 on: August 09, 2021, 07:51:50 am »

Just add a Replace():
Code: [Select]
https:////www.songfacts.com//facts//replace(regex([Artist]//[Name], /#^(.+?)(?: [[(]extended\b[^)\]]*[)\]])?$#/, 1),/ ,-)

This may work better with a simpler Regex that cuts anything after a parenthesis/bracket:
Code: [Select]
https:////www.songfacts.com//facts//replace(regex([Artist]//[Name], /#^(.+?)(\s?[\[(].*)?$#/, 1),/ ,-)
Logged

MarkCoutinho

  • Regular Member
  • Citizen of the Universe
  • *****
  • Posts: 676
Re: Manage links: how to replace spaces by a dash?
« Reply #2 on: August 09, 2021, 08:11:13 am »

Spot on!
Thank you very much!
Logged
Mark Coutinho
Dutch Top 40 collector of lyrics, sleeves and bios
Pages: [1]   Go Up