1
votes

I'm trying to extract the ContactLastName, by filtering out the ContactOwnerId.

First of all, I am extracting the "ContactOwnerId" from Sampler No. 1 through Regular Expression Extractor which is successful.

My RegEx Query is: "OWNERID":(\d+),

Now, I want the "LastName" by filtering out the "ContactOwnerId" from Sampler No. 2 through the Regular Expression Extractor.

My RegEx Query is: (?(?"OWNERID":(\d+),==\${GetContactOwnerId})(?"LASTNAME":"(.*?)"))

Note: The both "LastName" & "ContactOwnerId" can be extracted from Sampler No. 1 & 2, but I'm extracting the "ContactOwnerId" first from the Sampler No. 1 and then trying to extract the "LastName" from the Sampler No. 2 by comparing extracted "ContactOwnerId" with the current "ContactOwnerId".

The 2nd Regular Expression Extractor fails to extract, please verify and suggest the proper query.

Thanks

1

1 Answers

0
votes

The following way, the issue got resolved:

As mentioned I was extracting the "ContactOwnerId" from the Sampler No. 1 through the Regular Expression Extractor.

My RegExp Query was: "OWNERID":(\d+),

In the 2nd Sampler, I was trying to extract the LastName again through the Regular Expression Extractor.

My RegExp Query was: (?(?"OWNERID":(\d+),==\${GetContactOwnerId})(?"LASTNAME":"(.*?)"))

I felt it's complicated using the If-Then-Else pattern in RegExp Query, hence used the NOT operator in my RegExp Query and it worked successfully.

First, I tried with static data which worked error-less;

RegExp Query: "OWNERID":((?!724812)\d+),.*?"LASTNAME":"(.*?)"

I just appended the ?! in my RegExp which implies NOT operator.

Then, I tried extracting using the dynamic variable;

RegExp Query: "OWNERID":((?!${__V(${GetOwnerId})})\d+),.*?"LASTNAME":"(.*?)"

Here, I used the V Function which returns the value of evaluating a variable name.