匹配任何 URL 参数值的正则表达式(Perl 语法) [英] Regular Expression to match on any URL parameter value (Perl syntax)

查看:17
本文介绍了匹配任何 URL 参数值的正则表达式(Perl 语法)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在努力寻找一种允许我选择 URL 字符串的 Parameter=Value 元素的值部分的模式.我希望它足够通用,以便我可以用任何术语替换参数"并检索其值.

I am struggling to find a pattern that will allow me to select the value portion of a Parameter=Value element of a URL string. I would like it to be generic enough that I could replace the 'Parameter' with any term and retrieve its value.

例如,如果 URL 字符串是(它总是遵循这种一般形式):

For example, if the URL string is (it always follows this general form):

'http://www.mysite.com/home.aspx?userid=53&transaction=2&viewport=property'

我需要能够有选择地获取用户 ID、事务或视口或其他任何内容的价值部分.

I need to be able to the get value portion of userid or transaction or viewport, or whatever selectively.

最好是添加一个参数名称并将其后面的所有内容与 & 匹配.我尝试制作通用匹配字符串......糟透了.

Preferably it would be as easy as adding a parameter name and it matching eveything that follows its = to the &. My attempts to make a general purpose match string ... suck.

我不能使用 javascript 函数或任何东西,它必须是类似 perl 的正则表达式匹配(如果您好奇,这是用于 Apache JMeter 的).

I cannot use a javascript function or anything, it has to be perl-like regex matching (This is for use with Apache JMeter if you are curious).

我不擅长正则表达式 :-/在此先感谢您的帮助.

I suck at regex :-/ Thanks in advance for any help.

推荐答案

如果必须是正则表达式,

In case it has to be a regex,

/userid=([^&]*)/

这篇关于匹配任何 URL 参数值的正则表达式(Perl 语法)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆