大佬教程收集整理的这篇文章主要介绍了正则表达式[Python] 从 url 路径参数中提取,大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。
我有访问日志中的 URL。例子:
/someservice/US/getPersonFromAllAccessorIEsByDescription/67814/alloy%20nudge%20w
/someservice/NZ/asdNmasdf423-asd342e/getDealerFromSomethingSomething/FS443GH/front%20parking%20sen
我正在尝试在第一个日志中找到一个@H_874_13@仅匹配的正则表达式:
67814
alloy%20nudge%20w
第二个:
asdNmasdf423-asd342e
FS443GH
front%20parking%20sen
通过一些启发,我尝试使用 [a-zA-Z0-9_%-]{15,}|[A-Z0-9]{5,}
仅匹配长字符串,但函数名称(getPersonFromAllAccessorIEsByDescription、getDealerFromSomethingSomething)也被捕获。 >
我正在考虑可以做与 [a-zA-Z0-9_%-]{15,}
相同的正则表达式,但条件是它必须至少是一位数字,这样函数名称将被跳过。
谢谢
你的启发式很好,使用
\b(?=[a-zA-Z_%-]*[0-9])[a-zA-Z0-9_%-]{5,}
见proof。
@H_874_13@说明
--------------------------------------------------------------------------------
\b the boundary between a word char (\w) and
something that is not a word char
--------------------------------------------------------------------------------
(?= look ahead to see if there is:
--------------------------------------------------------------------------------
[a-zA-Z_%-]* any character of: 'a' to 'z','A' to
'Z','_','%','-' (0 or more times
(matching the most amount possiblE))
--------------------------------------------------------------------------------
[0-9] any character of: '0' to '9'
--------------------------------------------------------------------------------
) end of look-ahead
--------------------------------------------------------------------------------
[a-zA-Z0-9_%-]{5,} any character of: 'a' to 'z','A' to 'Z','0' to '9','-' (at least 5
times (matching the most amount possiblE))
以上是大佬教程为你收集整理的正则表达式[Python] 从 url 路径参数中提取全部内容,希望文章能够帮你解决正则表达式[Python] 从 url 路径参数中提取所遇到的程序开发问题。
如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。
本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。