我想将网址列表修剪为第一个文件夹
for example:
url.com/folder1/xxx/index.html
url.com/folder2/
url.com/folder3/xxx/yyyy/index.html
url.com/folder4/zzz/aaa/bbb/index.html
Output should look like this:
url.com/folder1/
url.com/folder2/
url.com/folder3/
url.com/folder4/
非常感谢任何帮助。 谢谢!
答案 0 :(得分:1)
查找: ^.*?\/.*?\/\K.*$
试试这个。替换为 empty string
。请参阅演示。
https://regex101.com/r/mS3tQ7/14
\K resets the starting point of the reported match. Any previously consumed characters are no longer included in the final match
答案 1 :(得分:0)