基于共同元素对URL进行分组

huangapple go评论66阅读模式
英文:

Group URLs based on common element

问题

我有一个数据集中的URL字段,我想要替换任何看起来像这样的URL:

/manage/{old_booking_ref}{number_id}GBBLADV8
/manage/{old_booking_ref}{number_id}GBAPTX8E
/manage/{old_booking_ref}{number_id}IEWWG9HG
/manage/{old_booking_ref}{number_id}IEY2DCPC

等等,

替换为这个:
/manage/{old_booking_ref}{number_id}

在Looker Studio中是否有方法可以做到这一点?

值得注意的是,这些URL末尾的ID总是以GB或IE开头。

我尝试在CASE语句中使用REGEXP_CONTAINS,但似乎它不识别%运算符,因为它没有改变任何东西。

英文:

I have a URL field in my dataset, and I want to replace any URLs that look like this:

/manage/{old_booking_ref}{number_id}GBBLADV8
/manage/{old_booking_ref}{number_id}GBAPTX8E
/manage/{old_booking_ref}{number_id}IEWWG9HG
/manage/{old_booking_ref}{number_id}IEY2DCPC

and so on,

With this:
/manage/{old_booking_ref}{number_id}

Is there a way to do this in Looker Studio?

It's worth noting that the ID at the end of these URLs always starts with either GB or IE.

I've tried using REGEXP_CONTAINS in a CASE statement, but it doesn't seem to recognise % operators because it didn't change anything.

CASE 
    WHEN REGEXP_CONTAINS(url, "/manage/{old_booking_ref}{number_id}GB%") 
    OR REGEXP_CONTAINS(url, "/manage/{old_booking_ref}{number_id}IE%") 
    THEN "/manage/{old_booking_ref}{number_id}"
  ELSE url
END

答案1

得分: 1

CASE
WHEN REGEXP_CONTAINS(url, "}(?:GB|IE)")
THEN "/manage/{old_booking_ref}{number_id}"
ELSE url
END

英文:

<!-- language-all: js -->

Can you try:

CASE 
    WHEN REGEXP_CONTAINS(url, &quot;}(?:GB|IE)&quot;)
    THEN &quot;/manage/{old_booking_ref}{number_id}&quot;
    ELSE url
END

基于共同元素对URL进行分组

答案2

得分: 0

"我假设您在另一列中有这个旧的预订参考和编号,因此您可以只需使用这些值更新该列"/manage/{old_booking_ref}{number_id}"。"

英文:

I assume that you have this old booking ref and number id in another column so you may just update the column with these values "/manage/{old_booking_ref}{number_id}"

huangapple
  • 本文由 发表于 2023年6月26日 17:30:17
  • 转载请务必保留本文链接:https://go.coder-hub.com/76555374.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定