INTERACT FORUM

More => Old Versions => JRiver Media Center 27 for Windows => Topic started by: MarkCoutinho on August 09, 2021, 02:31:28 am

Title: Manage links: how to replace spaces by a dash?
Post by: MarkCoutinho 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!
Title: Re: Manage links: how to replace spaces by a dash?
Post by: zybex 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),/ ,-)
Title: Re: Manage links: how to replace spaces by a dash?
Post by: MarkCoutinho on August 09, 2021, 08:11:13 am
Spot on!
Thank you very much!