Having problems with your account or logging in?
A lot of changes are happening in the community right now. Some may affect you. READ MORE HERE
RiseOfDeath Trusted Contributor.
Trusted Contributor.
307 views

LR RegExp troubles.

Hi guys. I've got a trouble with thise code, which I use  to parse answer for async request:

lr_save_param_regexp (
        aResponseBodyStr,
        aResponseBodyLen,
        "RegExp/IC=index(.+?)VRId-.", 
        "Ordinal=ALL",
        "ResultParam=Poll_Param",
         LAST );

The responce contains something like this example:

`7`1``0`br`0`ar`-1`size`6`index`2`cr`0`OP`iw`bc`S_BC3`1`0`FieldValues`0`ValueArray`<here some usefull payload, which parsing is the next step>*6*VRId-2

 

What can I do, to parse this (without creations my own parsing functions)?

 

 

0 Likes
4 Replies
Highlighted
JorgeDuran-PCLR Respected Contributor.
Respected Contributor.

Re: LR RegExp troubles.

Hello, 

For this scenario there is no function. 

You will have to perform your own function, our recommendation is in C language.

and then use the function for your recording. 

Regards,

Outstanding Contributor.. JHF Remmelzwaal Outstanding Contributor..
Outstanding Contributor..

Re: LR RegExp troubles.

1. your function call matches with your given response. (Note that in the documentation of 12.55 this functions is incorrect documented).

2. you can use this function according documentation in your 'Response Callback' function.

So if you do both things, what is the issue you have?

0 Likes
RiseOfDeath Trusted Contributor.
Trusted Contributor.

Re: LR RegExp troubles.

I've got LR 12.02. And I use it inside BC (which I set as ResponseCB). As result I have no parsed results. Seems that It's problem with last symbol in regexp (the dot) and my regexp too complex for LR. Because this regexp works fine:

index(.+?)VRId-

 

 

It there is no any move ways, I'll use own C-function as  @JorgeDuran-PCLR suggest.

0 Likes
Outstanding Contributor.. JHF Remmelzwaal Outstanding Contributor..
Outstanding Contributor..

Re: LR RegExp troubles.

I cannot test with LR 12.02. But I verified your code with a sample that I put into an empty script and enabled Parameter Logging:

vuser_init()
{
	char *p = "`7`1``0`br`0`ar`-1`size`6`index`2`cr`0`OP`iw`bc`S_BC3`1`0`FieldValues`0`ValueArray`<here some usefull payload, which parsing is the next step>*6*VRId-2";
	
	lr_save_param_regexp (
        p, strlen(p),
        "RegExp/IC=index(.+?)VRId-.", 
        "Ordinal=ALL", "ResultParam=Poll_Param", LAST );
	return 0;
}

I think that the 'dot' will not be the issue, but it might be bug. Do you always have a digid after 'VRId-'? Then you can replace the dot with \d to match with any digit. So your regexp argument will be:

"RegExp/IC=index(.+?)VRId-\\d"

 Note the  double \ to make it work in a C-string.

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.