Highlighted
Super Contributor.. Super Contributor..
Super Contributor..
446 views

Correlation - web.regSaveParamRegexp

Hi,

I am using Loadrunner 12.53, HTML/HTTP protocol.

I have the following string:

{"success":true,"data":[{"id":"748bc616f75","chunkingId":"20","mediaId":60000030,"documentId":130000062,"contexts":[]}]} 

I need to capture the value "2" from this string (mediaId and documentID). 

My regexp is:

web.regSaveParamRegexp({

paramName: 'documentId',

regExp: 'success":true,"data":[{"id":"748bc616f75","chunkingId":"{id}","mediaId":(.*?),"documentId":(.*?),"contexts":[]}]',

scope: 'body',

IgnoreRedirections: 'No'

}); 

However, I am getting error:  Error -35054: No substring to be saved in regular expression. Enclose part of the RE in parentheses "()" to save it to the parameter or use "Group=0" argument to save the entire RE match. 

Could anyone help me? 

Thanks

0 Likes
8 Replies
Highlighted
Respected Contributor.. Respected Contributor..
Respected Contributor..

Re: Correlation - web.regSaveParamRegexp

0 Likes
Highlighted
Outstanding Contributor.
Outstanding Contributor.

Re: Correlation - web.regSaveParamRegexp

I would first try to add "Group=0" to the call, like this

web.regSaveParamRegexp({
paramName: 'documentId',
regExp: 'success":true,"data":[{"id":"748bc616f75","chunkingId":"{id}","mediaId":(.*?),"documentId":(.*?),"contexts":[]}]',
"Group=0",
scope: 'body',
IgnoreRedirections: 'No'
});

0 Likes
Highlighted
Super Contributor.. Super Contributor..
Super Contributor..

Re: Correlation - web.regSaveParamRegexp

Hi,

I added “group: 0”, and tried.

Now I am getting this error - Error -35049: No match found for the requested parameter "documentId". Check whether the requested regular expression exists in the response data.

Thanks

0 Likes
Highlighted
Outstanding Contributor.
Outstanding Contributor.

Re: Correlation - web.regSaveParamRegexp

So this is the string to search, right?

{"success":true,"data":[{"id":"748bc616f75","chunkingId":"20","mediaId":60000030,"documentId":130000062,"contexts":[]}]} 

What eaxctly do you need to pull out of it again? I wasn't clear on that.

0 Likes
Highlighted
Super Contributor.. Super Contributor..
Super Contributor..

Re: Correlation - web.regSaveParamRegexp

Hi,

I want to save mediaId and documentId in a parameter.

0 Likes
Highlighted
Outstanding Contributor.
Outstanding Contributor.

Re: Correlation - web.regSaveParamRegexp

I think I follow. I would try these.

    web_reg_save_param_ex(
        "ParamName=pMediaId ",
        "LB=mediaId\":",
        "RB=,",
        SEARCH_FILTERS,
        "Scope=ALL",
        LAST);
    
    web_reg_save_param_ex(
        "ParamName=pDocumentId",
        "LB=documentId\":",
        "RB=,",
        SEARCH_FILTERS,
        "Scope=ALL",
        LAST);

    

0 Likes
Highlighted
Super Contributor.. Super Contributor..
Super Contributor..

Re: Correlation - web.regSaveParamRegexp

Hi,

Yes, this way it works.

However, I would like to know, is it possible to save these two id's using "regSaveParamRegexp" function?

Thanks

0 Likes
Highlighted
Outstanding Contributor.
Outstanding Contributor.

Re: Correlation - web.regSaveParamRegexp

I would think [0-9]{8} would work for the first value, and [0-9]{9} for the second.

But if you know more about the values that would help.

For example, does the "mediaId" always begin with "600"? If it does, you could grab it with:

600[0-9]{5}

0 Likes
The opinions expressed above are the personal opinions of the authors, not of Micro Focus. By using this site, you accept the Terms of Use and Rules of Participation. Certain versions of content ("Material") accessible here may contain branding from Hewlett-Packard Company (now HP Inc.) and Hewlett Packard Enterprise Company. As of September 1, 2017, the Material is now offered by Micro Focus, a separately owned and operated company. Any reference to the HP and Hewlett Packard Enterprise/HPE marks is historical in nature, and the HP and Hewlett Packard Enterprise/HPE marks are the property of their respective owners.