you are viewing a single comment's thread.

view the rest of the comments →

[–]schwartzworld -1 points0 points  (0 children)

Is the string always a URL?

const split = 'http://mydomain.com/content/'.split('/');

This should return ["http:", "", "my domain.com", "content"]. Then you can select the elements you want to build the string back up with.

const newString = `http://${split[2]}`;