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

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
Sign in to follow this  

×
×
  • Create New...