我习惯使用Java中的Regex,但是当我在https://www.youtube.com/watch?feature=player_detailpage&v=SVxB3Tk4O4A#t=430的JMeter中看到它们时,我感到很困惑
(。+?)是什么意思? 正则表达式(。+?)和(。*)之间有区别吗?
JMeter正则表达式“$ 1 $”相当于Java正则表达式“$ 1”? 根据Apache Regex(http://jmeter.apache.org/usermanual/component_reference.html#Regular_Expression_Extractor),它看起来是一样的。这是真的吗?
答案 0 :(得分:1)
正则表达式(。+?)和(。*)之间是否存在差异?
懒惰方式
.+? any character except \n (1 or more times
(matching the least amount possible))
贪婪方式
.* any character except \n (0 or more times
(matching the most amount possible))
换句话说:
.+?
匹配任何字符(换行符除外)
在一次和无限次之间,尽可能少地根据需要进行扩展 [lazy]
.*
匹配任何字符(换行符除外)
在零和无限次之间,尽可能多次,根据需要回馈 [贪婪]