regex - 如何使用正则表达式忽略 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
解决方案
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)
推荐阅读
- module - Moodle 语法上设置模块序列
- c - 如何使信号处理程序只运行一次并终止所有进程?
- node.js - 如何进行回调以返回承诺?我可以使用 Promise.resolve() 作为我的回调函数吗?
- uibutton - 在 Swift 4 中通过 for 循环创建具有唯一名称的按钮
- java - 更新 mongodb 中的双嵌套集合
- reactjs - 在渲染反应之前设置状态
- vba - VBA - 查找 lastColumn 并检查第一行是否为空
- arrays - Kotlin 中的数组声明
- node.js - AG Grid 可以在 NodeJS 上运行吗?
- javafx - 响应式 JavaFX BorderPane