【问题标题】:regex to extract HTML attribute value正则表达式提取 HTML 属性值
【发布时间】:2015-04-02 04:15:30
【问题描述】:

我有以下 HTML

<tr><td class="width35pct alignR"><span style="font-weight: bold;">TO :</span></td><td class="width40pct alignC"><input id="form:firstTON" name="form:firstTON" type="text" value="114" maxlength="17" tabindex="7" style="width:198px; margin: 5px 0 5px 0;" class="ui-inputfield ui-inputtext ui-widget ui-state-default ui-corner-all" /><script id="form:firstTON_s" type="text/javascript">//<![CDATA[PrimeFaces.cw('InputText','widget_form_firstTON',{id:'form:firstTON'});//]]><![CDATA[]]]]><![CDATA[></script></td><td class="alignl"><span style="font-weight: bold !important;" class="ar">number</span></td></tr>

我需要创建一个正则表达式来提取值“114”,这是“value”属性的值。

有什么帮助吗?

【问题讨论】:

  • 您使用的是什么语言
  • 我正在使用 Jmeter,我需要从响应中驱动这个值

标签: html regex jmeter


【解决方案1】:

使用JMeter,使用Regular Expression Extractor来完成这个任务。

Reference Name: mynum
Regular Expression: value="(.+?)"
Template: $1$
Match No.: 1

如果您指定使用Match No:,则规则如下:

0 = Random Match
1 = First Match 
2 = Second Match
etc....

然后就可以使用对应的变量来访问匹配了。 ${mynum_1}

【讨论】:

    猜你喜欢
    • 2011-07-28
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-02-01
    • 2010-09-25
    • 1970-01-01
    • 2015-02-26
    • 1970-01-01
    相关资源
    最近更新 更多