#include <StringConstants.au3> ; to declare the Constants of StringRegExp
#include <Array.au3> ; UDF needed for _ArrayDisplay and _ArrayConcatenate
Local $sRegex = "(?s) *<hashTree>. *<JSONPathAssertion.*?</JSONPathAssertion>. *<hashTree/>. *</hashTree>."
Local $sString = "<?xml version="1.0" encoding="UTF-8"?>" & @CRLF & _
"<jmeterTestPlan version="1.2" properties="5.0" jmeter="5.1.1 r1855137">" & @CRLF & _
" <hashTree>" & @CRLF & _
" <TestPlan guiclass="TestPlanGui" testclass="TestPlan" testname="test one" enabled="true">" & @CRLF & _
" <stringProp name="TestPlan.comments"></stringProp>" & @CRLF & _
" <boolProp name="TestPlan.functional_mode">false</boolProp>" & @CRLF & _
" <boolProp name="TestPlan.tearDown_on_shutdown">true</boolProp>" & @CRLF & _
" <boolProp name="TestPlan.serialize_threadgroups">false</boolProp>" & @CRLF & _
" <elementProp name="TestPlan.user_defined_variables" elementType="Arguments" guiclass="ArgumentsPanel" testclass="Arguments" testname="User Defined Variables" enabled="true">" & @CRLF & _
" <collectionProp name="Arguments.arguments"/>" & @CRLF & _
" </elementProp>" & @CRLF & _
" <stringProp name="TestPlan.user_define_classpath"></stringProp>" & @CRLF & _
" </TestPlan>" & @CRLF & _
" <hashTree>" & @CRLF & _
" <com.blazemeter.jmeter.threads.concurrency.ConcurrencyThreadGroup guiclass="com.blazemeter.jmeter.threads.concurrency.ConcurrencyThreadGroupGui" testclass="com.blazemeter.jmeter.threads.concurrency.ConcurrencyThreadGroup" testname="Thread - main" enabled="true">" & @CRLF & _
" <elementProp name="ThreadGroup.main_controller" elementType="com.blazemeter.jmeter.control.VirtualUserController"/>" & @CRLF & _
" <stringProp name="ThreadGroup.on_sample_error">continue</stringProp>" & @CRLF & _
" <stringProp name="TargetLevel">${__P(threads, 1)}</stringProp>" & @CRLF & _
" <stringProp name="RampUp">${__P(time, 1)}</stringProp>" & @CRLF & _
" <stringProp name="Steps">${__P(steps, 1)}</stringProp>" & @CRLF & _
" <stringProp name="Hold">${__P(hold, 3)}</stringProp>" & @CRLF & _
" <stringProp name="LogFilename"></stringProp>" & @CRLF & _
" <stringProp name="Iterations"></stringProp>" & @CRLF & _
" <stringProp name="Unit">M</stringProp>" & @CRLF & _
" </com.blazemeter.jmeter.threads.concurrency.ConcurrencyThreadGroup>" & @CRLF & _
" <hashTree>" & @CRLF & _
" <GenericController guiclass="LogicControllerGui" testclass="GenericController" testname="Simple Controller - main" enabled="true"/>" & @CRLF & _
" <hashTree>" & @CRLF & _
" <HTTPSamplerProxy guiclass="HttpTestSampleGui" testclass="HTTPSamplerProxy" testname="REQUEST1" enabled="true">" & @CRLF & _
" <boolProp name="HTTPSampler.postBodyRaw">true</boolProp>" & @CRLF & _
" <elementProp name="HTTPsampler.Arguments" elementType="Arguments">" & @CRLF & _
" <collectionProp name="Arguments.arguments">" & @CRLF & _
" <elementProp name="" elementType="HTTPArgument">" & @CRLF & _
" <boolProp name="HTTPArgument.always_encode">false</boolProp>" & @CRLF & _
" <stringProp name="Argument.value">{
" & @CRLF & _
" "version": "1.1",
" & @CRLF & _
" "test": {
" & @CRLF & _
"}</stringProp>" & @CRLF & _
" <stringProp name="Argument.metadata">=</stringProp>" & @CRLF & _
" </elementProp>" & @CRLF & _
" </collectionProp>" & @CRLF & _
" </elementProp>" & @CRLF & _
" <stringProp name="HTTPSampler.domain"></stringProp>" & @CRLF & _
" <stringProp name="HTTPSampler.port"></stringProp>" & @CRLF & _
" <stringProp name="HTTPSampler.protocol"></stringProp>" & @CRLF & _
" <stringProp name="HTTPSampler.contentEncoding"></stringProp>" & @CRLF & _
" <stringProp name="HTTPSampler.path"></stringProp>" & @CRLF & _
" <stringProp name="HTTPSampler.method">POST</stringProp>" & @CRLF & _
" <boolProp name="HTTPSampler.follow_redirects">false</boolProp>" & @CRLF & _
" <boolProp name="HTTPSampler.auto_redirects">false</boolProp>" & @CRLF & _
" <boolProp name="HTTPSampler.use_keepalive">true</boolProp>" & @CRLF & _
" <boolProp name="HTTPSampler.DO_MULTIPART_POST">false</boolProp>" & @CRLF & _
" <stringProp name="HTTPSampler.embedded_url_re"></stringProp>" & @CRLF & _
" <stringProp name="HTTPSampler.connect_timeout"></stringProp>" & @CRLF & _
" <stringProp name="HTTPSampler.response_timeout"></stringProp>" & @CRLF & _
" </HTTPSamplerProxy>" & @CRLF & _
" <hashTree>" & @CRLF & _
" <JSONPathAssertion guiclass="JSONPathAssertionGui" testclass="JSONPathAssertion" testname="JSON Assertion" enabled="true">" & @CRLF & _
" <stringProp name="JSON_PATH">$.status</stringProp>" & @CRLF & _
" <stringProp name="EXPECTED_VALUE">ok</stringProp>" & @CRLF & _
" <boolProp name="JSONVALIDATION">true</boolProp>" & @CRLF & _
" <boolProp name="EXPECT_NULL">false</boolProp>" & @CRLF & _
" <boolProp name="INVERT">false</boolProp>" & @CRLF & _
" <boolProp name="ISREGEX">false</boolProp>" & @CRLF & _
" </JSONPathAssertion>" & @CRLF & _
" <hashTree/>" & @CRLF & _
" <JSR223PreProcessor guiclass="TestBeanGUI" testclass="JSR223PreProcessor" testname="JSR223 PreProcessor" enabled="true">" & @CRLF & _
" <stringProp name="cacheKey">true</stringProp>" & @CRLF & _
" <stringProp name="filename"></stringProp>" & @CRLF & _
" <stringProp name="parameters"></stringProp>" & @CRLF & _
" <stringProp name="script">// period in the past - year-month-day, set from properties in User Defined Variables" & @CRLF & _
"" & @CRLF & _
"import java.time.Instant;" & @CRLF & _
"import java.time.temporal.ChronoUnit;" & @CRLF & _
"import groovy.json.JsonOutput;" & @CRLF & _
"import org.apache.commons.lang.RandomStringUtils;</stringProp>" & @CRLF & _
" <stringProp name="scriptLanguage">groovy</stringProp>" & @CRLF & _
" </JSR223PreProcessor>" & @CRLF & _
" <hashTree/>" & @CRLF & _
" <JSR223PostProcessor guiclass="TestBeanGUI" testclass="JSR223PostProcessor" testname="JSR223 PostProcessor" enabled="true">" & @CRLF & _
" <stringProp name="cacheKey">true</stringProp>" & @CRLF & _
" <stringProp name="filename"></stringProp>" & @CRLF & _
" <stringProp name="parameters"></stringProp>" & @CRLF & _
" <stringProp name="script">import java.time.Instant;" & @CRLF & _
"import java.time.temporal.ChronoUnit;</stringProp>" & @CRLF & _
" <stringProp name="scriptLanguage">groovy</stringProp>" & @CRLF & _
" </JSR223PostProcessor>" & @CRLF & _
" <hashTree/>" & @CRLF & _
" </hashTree>" & @CRLF & _
" <IfController guiclass="IfControllerPanel" testclass="IfController" testname="If Controller" enabled="true">" & @CRLF & _
" <stringProp name="IfController.condition">${__groovy(${random_variable} == 1)}</stringProp>" & @CRLF & _
" <boolProp name="IfController.evaluateAll">false</boolProp>" & @CRLF & _
" <boolProp name="IfController.useExpression">true</boolProp>" & @CRLF & _
" </IfController>" & @CRLF & _
" <hashTree>" & @CRLF & _
" <RandomController guiclass="RandomControlGui" testclass="RandomController" testname="Random Controller" enabled="true">" & @CRLF & _
" <intProp name="InterleaveControl.style">1</intProp>" & @CRLF & _
" </RandomController>" & @CRLF & _
" <hashTree>" & @CRLF & _
" <HTTPSamplerProxy guiclass="HttpTestSampleGui" testclass="HTTPSamplerProxy" testname="REQUEST2" enabled="true">" & @CRLF & _
" <boolProp name="HTTPSampler.postBodyRaw">true</boolProp>" & @CRLF & _
" <elementProp name="HTTPsampler.Arguments" elementType="Arguments">" & @CRLF & _
" <collectionProp name="Arguments.arguments">" & @CRLF & _
" <elementProp name="" elementType="HTTPArgument">" & @CRLF & _
" <boolProp name="HTTPArgument.always_encode">false</boolProp>" & @CRLF & _
" <stringProp name="Argument.value">{
" & @CRLF & _
" "version": "1.1",
" & @CRLF & _
" "test": {
" & @CRLF & _
"}</stringProp>" & @CRLF & _
" <stringProp name="Argument.metadata">=</stringProp>" & @CRLF & _
" </elementProp>" & @CRLF & _
" </collectionProp>" & @CRLF & _
" </elementProp>" & @CRLF & _
" <stringProp name="HTTPSampler.domain"></stringProp>" & @CRLF & _
" <stringProp name="HTTPSampler.port"></stringProp>" & @CRLF & _
" <stringProp name="HTTPSampler.protocol"></stringProp>" & @CRLF & _
" <stringProp name="HTTPSampler.contentEncoding"></stringProp>" & @CRLF & _
" <stringProp name="HTTPSampler.path"></stringProp>" & @CRLF & _
" <stringProp name="HTTPSampler.method">POST</stringProp>" & @CRLF & _
" <boolProp name="HTTPSampler.follow_redirects">false</boolProp>" & @CRLF & _
" <boolProp name="HTTPSampler.auto_redirects">false</boolProp>" & @CRLF & _
" <boolProp name="HTTPSampler.use_keepalive">true</boolProp>" & @CRLF & _
" <boolProp name="HTTPSampler.DO_MULTIPART_POST">false</boolProp>" & @CRLF & _
" <stringProp name="HTTPSampler.embedded_url_re"></stringProp>" & @CRLF & _
" <stringProp name="HTTPSampler.connect_timeout"></stringProp>" & @CRLF & _
" <stringProp name="HTTPSampler.response_timeout"></stringProp>" & @CRLF & _
" </HTTPSamplerProxy>" & @CRLF & _
" <hashTree>" & @CRLF & _
" <JSONPathAssertion guiclass="JSONPathAssertionGui" testclass="JSONPathAssertion" testname="JSON Assertion" enabled="true">" & @CRLF & _
" <stringProp name="JSON_PATH">$.status</stringProp>" & @CRLF & _
" <stringProp name="EXPECTED_VALUE">ok</stringProp>" & @CRLF & _
" <boolProp name="JSONVALIDATION">true</boolProp>" & @CRLF & _
" <boolProp name="EXPECT_NULL">false</boolProp>" & @CRLF & _
" <boolProp name="INVERT">false</boolProp>" & @CRLF & _
" <boolProp name="ISREGEX">false</boolProp>" & @CRLF & _
" </JSONPathAssertion>" & @CRLF & _
" <hashTree/>" & @CRLF & _
" </hashTree>" & @CRLF & _
" </hashTree>" & @CRLF & _
" </hashTree>" & @CRLF & _
" </hashTree>" & @CRLF & _
" </hashTree>" & @CRLF & _
" </hashTree>" & @CRLF & _
" </hashTree>" & @CRLF & _
"</jmeterTestPlan>"
Local $aArray = StringRegExp($sString, $sRegex, $STR_REGEXPARRAYGLOBALFULLMATCH)
Local $aFullArray[0]
For $i = 0 To UBound($aArray) -1
_ArrayConcatenate($aFullArray, $aArray[$i])
Next
$aArray = $aFullArray
; Present the entire match result
_ArrayDisplay($aArray, "Result")
Please keep in mind that these code samples are automatically generated and are not guaranteed to work. If you find any syntax errors, feel free to submit a bug report. For a full regex reference for AutoIt, please visit: https://www.autoitscript.com/autoit3/docs/functions/StringRegExp.htm