The regular expression in LoadRunner is one of the easiest options to implement the correlation logic for handling dynamic values in the script. web_reg_save_param_regex function helps to capture the dynamic values in the response using a regular expression token. The main advantage of web_reg_save_param_regexp over web_reg_save_param is that you have the option to escape the content (string) to capture the required value. See the example given in this post later. If you have expertise in writing the regular expression then web_reg_save_param_regexp is the ultimate option for you.

Why the function name is like this?

web_reg_save_param_regexp function is used for web protocol (denoted by ‘web’). This function registers a request (denoted by ‘reg’) to find out the dynamic value based on the regular expression (denoted by ‘regexp’). After registering the request, the next task is to save the dynamic value in a parameter (denoted by ‘save_param’ words). Hence it is named as ‘web_reg_save_param_regexp’.

Follow the navigation to open the web_reg_save_param_regexp input box:

  1. Press ‘Ctrl+Alt+B’ or View -> Steps Toolbox
  2. Type ‘web_reg_save_param_regexp’ in the search box. VuGen will show you the matched content.
  3. Double-click on the ‘web_reg_save_param_regexp’ function. The window will appear with the following inputs:
web_reg_save_param_regexp function in LoadRunner
Figure 01

Attributes of ‘web_reg_save_param_regexp’:

a. Parameter Name: The name of the correlation parameter that saves the dynamic value. This is a mandatory field.

b. RegExp: This is a mandatory attribute. In this attribute, you have to write a regular expression to capture the dynamic data. Refer to the post to learn how to write regular expressions.

c. Group: This is an optional attribute. Group attribute provides the option to capture multiple dynamic values using the same regular expression. If you pass 0 (zero) then it saves the entire expression along with the specified text. The maximum value is 10. Example: If you have specified the regular expression as given below and you need to capture SurName, then Group will be 2

"RegExp=Name=(.*?) and SurName=(.*?)",

d. DFEs: This is an optional attribute. It is a comma-separated list of Data Formats Extensions that are to be used before the required search operation is to be performed.

e. Ordinal (ORD): This is an optional attribute. It is used to capture dynamic values on a specific occurrence. If you specify the value of Ordinal (ORD) =ALL then all the occurrences of the matched boundary are saved in an array. Each element of the array is represented by the ParamName_index. In the following example, the parameter name is c_custID:


The first match is saved as c_custID_1, the second match is saved as c_custID_2, and so forth. You can retrieve the total number of matches by using the following parameter ParamName_count. For example, to retrieve the total number of matches saved to the parameter array you can use the below statement:


h. Warn if text was not found (Default is Error) (NotFound): This is an optional attribute and has ‘Error’ as a default value. This option handles the situation when the defined boundary does not match and generates an empty string. It has the following input options:

  • ERROR: This is a default value. When a boundary is not found then LoadRunner highlight it as an error in the log.
  • WARNING: LoadRunner does not issue an error. If the boundary is not found, it sets the parameter count to 0 and continues executing the script. The ‘warning’ option is good when you want to see whether the string was found or not, but do not want the script to fail.

Note: If ‘Continue on Error’ option is enabled for the script then even when NOTFOUND is set to ‘ERROR’; the script continues when the boundary is not found, but an error message is written to the Extended log file.

i. Scope: This attribute comes under the ‘Filters (SEARCH_FILTERS)’ option. This is also an optional attribute with the default value “All”. It specifies the scope of the search for dynamic value within the response. The input options are:

  • All: The scope of the search is body, headers, and resources 
  • Headers: It indicates to search only in the headers
  • Body: The scope of the search is only body, not headers
  • Cookies: The scope of the search is only cookies.

j. Header Name (HeaderNames): To enable this attribute you need to select the ‘Scope’ type as Headers. Here, you can provide a comma-separated list of HTTP response header names then LoadRunner will search the dynamic values only in the specified headers. This is an optional attribute.

k. RequestURL: The dynamic values will be searched only in the responses of specified requests. The URL can contain the * wildcard. It is specially used to correlate the value coming in the response of flex_amf_call.

l. Content Type (ContentType): LoadRunner searches the dynamic value in the responses with the specified ContentType header. The ContentType can contain the * wildcard. This is an optional attribute.

m. Frame ID (RelFrameID): This is an optional attribute. The hierarchy level of the HTML page relative to the requested URL. The possible values are ‘All’ or a number.

Note: GUI level scripts do not support RelFrameID.

n. Ignore Redirection (IgnoreRedirections): This is an optional attribute with the default value “No”. The inputs are:

  • Check (Yes): By setting the ‘IgnoreRedirections=Yes’, it instructs LoadRunner not to search the dynamic value in the response of the redirected request. You can identify the redirected request by its response code HTTP 3XX.
  • Uncheck (No): LoadRunner even searches for the existence of dynamic value in the response of the redirected request.

Example: ‘web_reg_save_param_ex’ with attributes

Figure 02
	"RegExp=Name=(.*?) and SurName=(.*?)",

How to use the web_reg_save_param_regexp function in the script?

  1. Identify the dynamic value in the script (How?)
  2. Locate the cursor before the request which has a dynamic value in the response.
  3. Right click -> Insert -> New Step -> Steps Toolbox -> (Search for keyword) web_reg_save_param_regexp -> (Double Click on) web_reg_save_param_regexp -> ‘web_reg_save_regexp – Save Data to a Parameter’ window will open -> Provide the required input and press Ok.
    If you know the correct syntax and attributes of the web_reg_save_param_regexp function then you can simply type in the script.

Important Point: LoadRunner’s correlation functions are always written/placed before the request whose response contains the dynamic value.

In addition, there are four more correlation functions in the LoadRunner. Refer to the link to get more details:

  1. web_reg_save_param
  2. web_reg_save_param_ex
  3. web_reg_save_param_xpath
  4. web_reg_save_param_json
  5. web_reg_save_attrib

Frequently used regular expression tokens:

  1. (.*?) – It matches any string including a new line
  2. (.+?) – It matches the strings including letters, digits and space (exclude new line)
  3. ([a-zA-Z]+) – It matches any characters between a-z or A-Z
  4. ([\d]) OR ([0-9]+) – It matches any decimal digit

Refer to the link to learn more about regular expression tokens and how to write them.

How to escape the content in the response and capture the correct value?

Example: A request has the below response including class, type, category, foodcategory and name.


If you want to capture the names of all the mammals then probably you will write like this:


By using an escape token you can shorten the token string like this:


Try at your end and see the magic!

9 thoughts on “web_reg_save_param_regexp”

  1. How to write regular expression for below scenario and take input data individually and total count under specific category in vugen

    “ab”: “8888”
    “ab”: “7777”

    “License2”: [
    “ab”: “111111”
    “ab”: “222222”

      • Yes.
        For example it should work like below:
        for license1 should store the total count as 2 and should iterate n number of counts. here its 2 times
        for license2 should store the total count as 2 and should iterate n number of counts. here its 2 times

        • Hope i am not confusing.

          Just let me know how to write regular expression and take input data individually and total count under license1 and license2 separately.

        • If License1 is constant then you can use the below RegEx:
          “License1”.\W+“ab”: “([0-9]+)”\W+“ab”: “([0-9]+)”

          In case you want to capture all the “ab” value irrespective of License then use the below RegEx:
          “License\d”.\W+“ab”: “([0-9]+)”\W+“ab”: “([0-9]+)”

  2. Hi ,
    Does the group save the both dynamic values using one expression .?
    Example :
    Server response

    My Regular expression


    I have given group as 0 but its capturing entire expression . ie draw”:2,”recordsTotal”:17820
    instead of giving “2 ” and “17820”

    can you help me to understand how I can capture only “2 ” and “17820” using one expression.


      • But if we place 2, it will capture 17820 only. right? and now 2.
        Group=0 stands for complete string(including search criteria).
        Group=1 stands for first dynamic value(from regular expression) in search string
        Group=2 stands for first dynamic value(from regular expression) in search string


Leave a Comment