假设我有一个这样的网址列表:
https://moz.com/
https://moz.com/about
https://moz.com/about/contact
https://moz.com/about/jobs
https://moz.com/beginners-guide-to-seo
https://moz.com/blog
https://moz.com/blog/category/advanced-seo
https://moz.com/blog/advanced-seo/technical
https://moz.com/blog/advanced-seo/content
https://moz.com/blog/googles-walled-garden
https://moz.com/blog/local-search-ranking-factors-survey-results-2017
https://moz.com/explorer
https://moz.com/help
https://moz.com/help/guides
https://moz.com/help/guides/moz-pro-overview
我希望它根据结构的深度显示在不同的列中。就像URL的每个部分都是站点层次结构中的级别一样,我希望将层次结构可视化为:
https://moz.com/
https://moz.com/about
https://moz.com/about/contact
https://moz.com/about/jobs
https://moz.com/beginners-guide-to-seo
https://moz.com/blog
https://moz.com/blog/advanced-seo
https://moz.com/blog/advanced-seo/technical
https://moz.com/blog/advanced-seo/content
https://moz.com/blog/googles-walled-garden
https://moz.com/blog/local-search-ranking-factors-survey-results-2017
https://moz.com/explorer
https://moz.com/help
https://moz.com/help/guides
https://moz.com/help/guides/moz-pro-overview
我该怎么做?我已经尝试过使用split函数,但这不起作用,因为它只是将URL的不同部分拆分为不同的列,而不是将整个URL拆分为一致的列。
提前致谢:)
答案 0 :(得分:3)
假设链接的范围是A:A
:
=ArrayFormula(COUNTIF(REGEXMATCH(A2,$A$1:A1), true))*1
放入B2并将其拖放=REPT(" ",B1)&A1
放入C1并将其向下拖动。<强> EDIT1 强>
以下是执行相同操作的单一公式:
=ARRAYFORMULA(rept(" ",MMULT(
--(REGEXMATCH(A1:A15,TRANSPOSE(OFFSET(A1:A15,1,)))),SIGN(A1:A15<>""))-1)&A1:A15)
<强> EDIT2 强>
这是一个很棒的解决方案,非常感谢你。但似乎我跑了 在最后包含.html的网站的问题 (moz.com/about.html但moz.com/about/contact.html等)。任何 想法如何绕过这个?
=ARRAYFORMULA(rept(" ",MMULT(--(REGEXMATCH(A1:A15,REGEXREPLACE(TRANSPOSE(OFFSET(A1:A15,1,)),"\.html$",""))),
SIGN(A1:A15<>""))-1)&A1:A15)
注意: