How to replace the host part of a URL using javascript regex. This can be any kind of URL with or without http. Assume this text is from the content of a json file.
OldText:
{
"auth" : {
"login" : "http://local.example.com:85/auth/signin",
"resetpass" : "http://local.example.com:85/auth/resetpass",
"profile" : "http://local.example.com/auth/profile"
}
}
Expecting a solution like:
var NewText = OldText.replace (/(some regex)/g, 'example.com');
To get NewText as:
{
"auth" : {
"login" : "http://example.com:85/auth/signin",
"resetpass" : "http://example.com:85/auth/resetpass",
"profile" : "http://example.com/auth/profile"
}
}
I found the same here, but that regex won't work in javascript.
Note: I'm looking for the Regex.