修剪网址的文件夹路径而不会丢失Google表格中的第一个文件夹 [英] Trimming Folder Path of a Url Without Losing First Folder In Google Sheets

查看:35
本文介绍了修剪网址的文件夹路径而不会丢失Google表格中的第一个文件夹的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在Google表格中:我想修剪到第一个文件夹的网址列表

例如:

  url.com/folder1/xxx/index.htmlurl.com/folder2/url.com/folder3/xxx/yyyy/index.htmlurl.com/folder4/zzz/aaa/bbb/index.html 

输出应如下所示:

  url.com/folder1/url.com/folder2/url.com/folder3/url.com/folder4/ 

我需要找到一个可以在Google表格中使用的公式,该公式可以轻松地一次性处理至少10,000个网址的所有工作?

我找到了此工具


OLD 答案

您认为正确,并且在regex101中具有正确的公式.

您也可以将其用于Google表格

= ArrayFormula(IFERROR(REGEXEXTRACT(A1:A,``^([^ \/] * \/[^ \/] *)'')))))

In Google Sheets: I would like to trim a list of urls to first folder

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/

I need to find a formula I can use in Google Sheets, which easily takes care of this all at once for at least 10,000 urls?

I found this tool https://regex101.com/r/aS7zX3/3 However, it does not work when you enter more than 1000 urls.

Any help would be much appreciated. Thanks!

解决方案

NEW answer because you comment "the case when the url is "es-la.domain.com/peter.75054" "

With this formula everything is correct

=ArrayFormula(IFERROR(REGEXEXTRACT(A1:A,"\w+.\w+/\w+")))


OLD answer

You think correct and have correct formula in regex101.

You can make it for Google Sheets also

=ArrayFormula(IFERROR(REGEXEXTRACT(A1:A,"^([^\/]*\/[^\/]*)")))

这篇关于修剪网址的文件夹路径而不会丢失Google表格中的第一个文件夹的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆