I have string that contains a random url:
http://google.com/vocab/prefix#Billy
That needs to be transformed so that everything up to, and including the first # is replaced with the value between the last / and the first # followed by a :.
The result would be:
prefix:Billy
More examples:
http://some.url/a/path#elephant --> path:elephant
http://random.com/cool/black/beans/thing#Bob --> thing:bob
I understand how to capture the prefix part /([^\/]+(?=#))/, but I'm struggling to do a string replace because I can't figure out how to capture the part I need to replace.
myString.replace(/([^\/]+(?=#))/, '$1:')
I would prefer to use string.replace with regex if at all possible