Examples

Extract a URL parameter value

Content: <a href="/page.jsp?kind=1&param1=value1&param2=value2">

Regex to extract value1 (only param1 is dynamic):

<a href="/page.jsp\?kind=1&param1=(.*?)&param2=value2">

Regex to extract value1 (all parameters dynamic):

<a href="/page.jsp\?.*?param1=([^&"]*)

Regex to extract value1 (where only the kind=1 links are to be taken into account):

<a href="/page.jsp\?kind=1.*?param1=([^&"]*)

Comments:

  • The first "?" is escaped with a backslash as it is a special character.

  • The first dynamic part, ".*?" , means "any character followed by 'param1='" in this instance. The question mark "?" means that the first occurrence matched must be used.

  • ([^&"]*) means "any character except '&' and '"', several times". The parentheses are required to define the group. The first group ($1$ in NeoLoad), refers to this matching part.

Extract a form parameter value

Content:

<form action="doit.jsp" method="post">
    <input type="hidden" name="myHiddenField" value="hidden information">
    Name:      <input name="cn" type="text" value="filled value"><br>
    <input name="myRadioField" value="val1" type="radio">Radio Value 1<br>
    <input name="myRadioField" value="val2" type="radio" checked="checked">
    Radio Value 2<br>
    <input type="checkbox" name="myCheckbox" value="checkBoxValue" checked="checked">
    A checkbox<br>
    <select name="dropDownList">
      <option value="val1">list choice 1
      <option value="val2" selected>list choice 2
      <option value="val3">list choice 3
    </select><br>
    <input value="Send" type="submit"><input type="reset">
</form>

The form looks like this:

Extract HTTP headers

Content:

Content-Type: text/html
Content-Length: 163
myHeader: myValue
Date: Thu, 03 Feb 2005 16:44:33 GMT
Server: Apache-Coyote/1.1

Regex: myHeader: (.*)

Comment: (.*) means "any character, except the newline character". The parentheses are required to define a group. Extract the header value in NeoLoad using $1$.

Extract miscellaneous values

Content: <div class ="welcomebar"> Welcome: John Doe </div>

Regex: <div class ="welcomebar"> Welcome: (\w* \w*) </div>

Comments:

  • (\w* \w*) means "two words separated by a space". The parentheses are required to define a group. The first and unique group refers to ''(\w* \w*)". Therefore, use $1$ in NeoLoad to extract both first and last names.

  • Using "(\w*) (\w*)" instead of "(\w* \w*)" may be used to extract the first and last name separately. In this case, use $1$ to extract the first name and $2$ the last name.