简体   繁体   English

使用正则表达式提取器来提取值?

[英]Using regular expression extractor to extract a value?

在此输入图像描述 在此输入图像描述 I am trying to extract the value from the following code. 我试图从以下代码中提取值。 Even though my regex expression is fine it is still not extracting the value. 即使我的正则表达式很好,它仍然没有提取值。

token" value="(.+?)"

this does give me the exact match which I checked using regex101.com 这确实给了我使用regex101.com检查的完全匹配

<input type="hidden" name="token" value="GSYGEP2UUWOTMZ2SFV1G5D2M8L247KIG">

what the regex expression should be 正则表达式应该是什么

Your original regular expression is just fine: 你的原始正则表达式很好:

value="(.+?)"

It might be additional spaces, or code problems with it. 它可能是额外的空格或代码问题。 Let's remove the token" or try to escape " , if necessary. 如有必要,让我们删除token"或试图逃跑"

DEMO 1 演示1

DEMO 2 演示2

Reference: 参考:

Try this 尝试这个

<input(?=(?:[^>"']|"[^"]*"|'[^']*')*?\sname\s*=\s*(['"])\s*token\s*\1)(?=(?:[^>"']|"[^"]*"|'[^']*')*?\svalue\s*=\s*(['"])((?:(?!\2)[\S\s])*)\2)\s+(?:"[\S\s]*?"|'[\S\s]*?'|[^>]*?)+>

The Value content you're after is in Capture Group 3 您所追求的价值内容位于Capture Group 3

https://regex101.com/r/HJhStT/1 https://regex101.com/r/HJhStT/1
https://regex101.com/r/8BWONb/1 https://regex101.com/r/8BWONb/1

Explained 解释

 < input                # Input tag

 (?=                    # Name attribute: Assert (a pseudo atomic group)
      (?: [^>"'] | " [^"]* " | ' [^']* ' )*?
      \s name  \s* = \s*     # name = 
      ( ['"] )               # (1), Quote
      \s* token \s*          # token
      \1 
 )
 (?=                    # Value attribute
      (?: [^>"'] | " [^"]* " | ' [^']* ' )*?
      \s value  \s* = \s*    # value =
      ( ['"] )               # (2), Quote
      (                      # (3 start), value content
           (?:
                (?! \2 )
                [\S\s] 
           )*
      )                      # (3 end)
      \2 
 )
 # Just get rest of tag
 \s+ 
 (?: " [\S\s]*? " | ' [\S\s]*? ' | [^>]*? )+
 >

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 Jmeter 正则表达式提取器提取输入值 - Jmeter Regular Expression Extractor to extract an input value 使用正则表达式提取器提取一组参数末尾的值的正则表达式 - Regular expression to extract a value at end of a set of parameters with Regular Expression Extractor 如何从使用 JMeter 中的正则表达式提取器提取的多个值中提取单个 Header 值? - How to extract single Header value from multiple values extracted using regular expression extractor in JMeter? 如何使用正则表达式提取器从jmeter中的响应中提取值 - how to use Regular expression extractor to extract value from response in jmeter 如何使用正则表达式提取器从响应头中提取元素 - How to extract the element from the response header using Regular Expression Extractor JMeter - 使用正则表达式提取器提取表单的操作属性 - JMeter - Extract Form's action attribute using Regular Expression Extractor 如何在JMeter中使用正则表达式提取器提取某些值? - How to extract certain values using regular expression extractor in JMeter? 如何使用正则表达式提取器在jmeter中提取json响应数据? - how to extract json response data in jmeter using regular expression extractor? 如何使用正则表达式提取器提取jmeter中的Json值? - How to extract the Json values in jmeter using regular expression extractor? 使用Jmeter中的正则表达式提取器从JSON响应中提取值 - Extracting a value from JSON Response using Regular Expression Extractor in Jmeter
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM