Jump to content
WAPT Forum
Sign in to follow this  
Pooja joshi

Include use of variable in Search Parameter Boundries

Recommended Posts

Hi,

 

Search Parameter is very useful function. It becomes more useful if we can use variables for boundaries.

 

So that complex extraction of variables becomes little easier and helpful as it can handle dependency.

 

Warm Regards,

 

Pooja

Share this post


Link to post
Share on other sites

Hi,

 

You can use JavaScript processing. Here is the code analogous to the “Search Parameter” function:

 

var str = context.responseBody;//input

var left = context.variable("left");//left boundary

var right = context.variable("right");//right boundary

var leftIndex = str.indexOf(left);

var rightIndex = -1;

if(leftIndex != -1)

{

rightIndex = str.indexOf(right,leftIndex+left.length);

}

if(rightIndex != -1)

{

str = str.slice(leftIndex+left.length,rightIndex);

context.variable("str")=str;// return string

}

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×