正则表达式在结果树中正确处理响应
当我使用Jmeter中的Variable将提取的值传递给后续请求时,新请求不会从Regex变量获取值。请告诉我这里缺少什么?
{" TimeSheetIID":138701753.0," CrewAssignedHourID":" ID138701753""说明":" ""起始日期":空," TimeSheetType":3," EnterTimeBy":0,"状态":&#34 ;新"" IncludeAllBookings":0.0"订单":[]," SelectedOrders":[],"资源&#34 ;: []," SelectedResources":[],"位置":[]," SelectedPositions":[]," ViewModelState":空, " ScreenId":空," ScreenSecurityDefinitions":空," DirtyFields":空," UserDefinedFields":空,"请将isDeleted&# 34;:假," IsSelected":假," IID":138701753.0}
经过测试的正则表达式对上述响应和工作 (?< =" TimeSheetIID":)(。)*(?= 0,"乘员) 创建了带有变量名称tid
的Reg表达式提取器新请求未从正则表达式中提取数据
POST数据: {" fieldiid":" 0"" parentjson":" {\" TimeSheetIID \": $ {TID} 下,\" CrewAssignedHourID \":\" \" \"说明\":\ " \" \"起始日期\":空,\" TimeSheetType \":3,\" EnterTimeBy \":0,\& #34;状态\":\"新\" \" IncludeAllBookings \":0,\"订单\":[] ,\" SelectedOrders \":[],\"资源\":[],\" SelectedResources \":[],\&#34 ;位置\":[],\" SelectedPositions \":[],\" ViewModelState \":空,\" ScreenId \&#34 ;:空,\" ScreenSecurityDefinitions \":空,\" DirtyFields \":空,\" UserDefinedFields \":空,\&#34 ;请将isDeleted \":假,\" IsSelected \":假,\" IID \": $ {TID} }"}
答案 0 :(得分:0)
从响应JSON中提取键值对时,最好使用JSONPATH而不是RegExp。我在JMeter 4.0中尝试了你的正则表达式,它没有用。
观察到org.apache.oro.text.MalformedCachePatternException: Invalid expression:
我可以使用此RegExp -
成功提取TimeSheetIID的值"TimeSheetIID":(.+?)\.
更新:这是实际工作的JMeter脚本的快照。 PFA Working script snapshot
答案 1 :(得分:0)
我在这里尝试了正则表达式https://regex101.com
TimeSheetIID":(\d+.?\d*),"CrewAssignedHourID":"(\w+)",
(\ d +。?\ d *)会得到时间表十进制数。 (\ w +)会让你的船员AssignedHourId。
\d+ matches a digit (equal to [0-9]) + Quantifier — Matches between one and unlimited times, as many times as possible, giving back as needed (greedy) .? matches any character (except for line terminators) ? Quantifier — Matches between zero and one times, as many times as possible, giving back as needed (greedy) \d* matches a digit (equal to [0-9]) * Quantifier — Matches between zero and unlimited times, as many times as possible, giving back as needed (greedy)
答案 2 :(得分:0)