想提取在URL中 "cta="之后直到& 符号的右边出现的Word。

问题描述 投票:1回答:1

我正在使用Google Data Studio,我只是想提取紧接在 cta= 直到 & 符号(见下文)。请看,这个词 cta 可能会在URL中出现两次,但我只想让第一次的 cta 要提取的内容。

我目前使用的是下面的RegEx。

REGEXP_EXTRACT(Page, '((?i)cta=.*&+)')

它给我的结果如下

cta=productpage-calculator-mobile-floating-personalloan&cta=productpage-calculator-mobile-floating-personalloan&

的网址。

webformsonlineformpersonal-loanwebpersonalloan.aspx?cta=productpage-calculator-mobile-floating-personalloan&cta=productpage-calculator-mobile-floating-personalloan&cta=productpage-calculator-mobile-floating-personalloan。

如何修改,才能提取出后面的字。cta= 直到 &?

regex google-data-studio
1个回答
0
投票

使用下面的模式,以及一个围绕你实际想要匹配的单一捕获组。

REGEXP_EXTRACT(Page, '(?i)cta=([^&]+)')

查看下面的链接以获得一个有效的regex演示。

演示

该模式工作原理如下:

(?i)cta=  match "cta=" in any case
([^&]+)  then match any number of characters following which are NOT &
         this captures everything until either the first & separator or the end of the URL
© www.soinside.com 2019 - 2024. All rights reserved.