單挑我有一個這樣的網址:http://127.0.0.1:7000//test//test//index.html
如何更換雙/多斜線的URL
預期輸出:http://127.0.0.1:7000/test/test/index.html
我用這個表達式:[^http:](\/{2,})
,輸出爲:http://127.0.0.1:700/test/test/index.html
的匹配爲:0 // '//'
這裏是演示:https://www.debuggex.com/r/dXZouvlec4srhg8i
我在哪裏錯了?
你有'javascript'版本嗎? – Jack
's.replace(/(https?:\/\ /)|(\ /)+/g,「$ 1 $ 2」);' –
對不起,混淆了各種語言,但它基本相同,請參閱JavaScript版本。 –