remove duplicate forward slashes from the URL [duplicate] December 31, 2023 by Tarik You can use: abc.replace(/([^:]\/)\/+/g, "$1"); Working Demo Update: Already answered by Halcyon