更新时间:2023-02-23 13:43:15
你可以使用这样的正则表达式:
You could use a regex like this:
(https?://)(.*?)(/.*)
正如您在替换部分中看到的,您可以使用捕获组并连接您想要生成所需网址的字符串.
As you can see in the Substitution section, you can use capturing group and concatenates the strings you want to generate the needed urls.
正则表达式的思路是捕获域前后的字符串,使用\1
+ staticpages
+ \3
.
The idea of the regex is to capture the string before and after the domain and use \1
+ staticpages
+ \3
.
如果您想将协议更改为 ftp,您可以使用捕获组索引并使用此替换字符串:
If you want to change the protocol to ftp, you could play with capturing group index and use this replacement string:
ftp://\2\3
所以,你会:
ftp://localhost:3000/something
ftp://www.domainname.com/something
ftp://domainname.com/something