String manipulations

String manipulations

Hello,

I have this string:

  1. Name1-Color-1.jpg - https://example.com/100 Name2-Color-1.jpg - https://example.com/102 Name1-Color-2.jpg - https://example.com/103 Name2-Color-2.jpg - https://example.com/101  

I need for example, the URLs that are Name1-Color to be saved in an array with the same name as the file without the number in front of it or the extension. The expected result is this:

  1. {"Name1-Color": "https://example.com/100,https://example.com/103"},{"Name2-Color": "https://example.com/101,https://example.com/102"}

I need this result to be able to iterate with them in another function.

I understand that this could be done with regex but I'm not very good with string manipulations or regex. Can you help me?

Thank you all very much!