regex - 将单元格中的文本限制在找到的倒数第二条
问题描述
链接由不同数量的条组成,但最后一个条和倒数第二条之间包含的内容对我不感兴趣,我可以使用什么公式?
原来的:
https://int.soccerway.com/national/czech-republic/czech-liga/20192020/championship-round/r54505/
https://int.soccerway.com/national/england/championship/20192020/regular-season/r53782/
https://int.soccerway.com/national/finland/veikkausliiga/2020/regular-season/r56520/
https://int.soccerway.com/national/germany/play-offs-12/20192020/s17666/
https://int.soccerway.com/national/germany/play-offs-23/20192020/s17670/
https://int.soccerway.com/national/norway/1-division/2020/regular-season/r56858/
https://int.soccerway.com/national/sweden/superettan/2020/s18293/
https://int.soccerway.com/national/united-states/nwsl-challenge-cup/2020/preliminary-round/r58293/
预期结果:
https://int.soccerway.com/national/czech-republic/czech-liga/20192020/championship-round/
https://int.soccerway.com/national/england/championship/20192020/regular-season/
https://int.soccerway.com/national/finland/veikkausliiga/2020/regular-season/
https://int.soccerway.com/national/germany/play-offs-12/20192020/
https://int.soccerway.com/national/germany/play-offs-23/20192020/
https://int.soccerway.com/national/norway/1-division/2020/regular-season/
https://int.soccerway.com/national/sweden/superettan/2020/
https://int.soccerway.com/national/united-states/nwsl-challenge-cup/2020/preliminary-round/
测试失败:
REGEXEXTRACT('Página1'!T2:T,
REGEXREPLACE('Página1'!T2:T,"(https?:\/\/([\w.-]+\/){6})","($1)"))
我测试的模型不起作用,因为倒数第二条并不总是在位置 6,所以它不能满足我的需要。
解决方案
您可以匹配最后一个文本,/
并在第 1 组中捕获所有之前的内容。
在替换使用组 1 中。
例如单个条目=REGEXREPLACE(A1, "(https?://\S+/)[^\s/]+/", "$1")
(https?://\S+/)[^\s/]+/
推荐阅读
- java - 静态内部类字段值(默认为 0,为什么?)
- java - SoapHeaderElement 孩子?
- swift - 我可以使用 DispatchSemaphore 来控制主队列上的线程吗?
- c# - 如何在 C# 的 exe 中使用或访问新创建的管道变量,以便我可以在 azure dev-ops 构建管道中的程序内部赋值?
- laravel - firebid 2.5.1服务器第一次执行sql查询时间长
- r - 如何将矩阵相乘并相加?
- angular - rxjs: withLatestFrom 优先级
- spring-boot - 将动态响应映射到 RestTemplate 中的 Java 对象
- ios - crashlytics 中的两个应用
- c# - 是否有理由乘以整数“x”,然后除以相同的“x”作为双精度数?