我正在使用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=
直到 &
?
使用下面的模式,以及一个围绕你实际想要匹配的单一捕获组。
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