首页 > 解决方案 > 如何使用正则表达式忽略 URL 中的 32 个字符

问题描述

我需要在我的谷歌分析中设置步骤漏斗,但为此,在 URL 中,我试图找到一些方法来忽略“example.com/39921713197/checkouts/” - 和 - 之间的 32 个字符?previous_step =contact_information&step=shipping_method”。在这种情况下,忽略通常以这种格式排列的 32 个字符(不是常量):“b625d2e28d1c2f14bfdbf8e051787cb4”。

我应该使用什么正则表达式来忽略它?如何?

已经尝试过:[a-z0-9], (.)+

我的完整网址:example.com/39921713197/checkouts/b625d2e28d1c2f14bfdbf8e051787cb4?previous_step=contact_information&step=shipping_method

标签: regexgoogle-analytics

解决方案


Making my comment a complete answer; perhaps just finding the 32 chars and splitting on ? would work!

/[a-f\d]{32}\?(.+)$
  • find 32 hex characters
  • find a literal ?
  • take make a group of all the remaining characters (at least one) until the end of the string (url)

推荐阅读