英文:
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, "}(?:GB|IE)")
THEN "/manage/{old_booking_ref}{number_id}"
ELSE url
END
答案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}"
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论