Substr Function

Description:

This function returns a substring of a source string.

Format:

HTTP GET HOST Hostname URL url szVar = Substr( requestOptions, strLeft, strRight [ [, iOffsetOrOccurence [, substrOptions] ] | [ strOffset [, substrOptions ] ] ] );
HTTP GET HOST Hostname URL url szVar = Substr( requestOptions, iPos, strRight [ [, iOffsetOrOccurence [, substrOptions] ] | [ strOffset [, substrOptions ] ] ] );
HTTP GET HOST Hostname URL url szVar = Substr( requestOptions, strLeft, iLength [ [, iOffsetOrOccurence [, substrOptions] ] | [ strOffset [, substrOptions ] ] ] );
HTTP GET HOST Hostname URL url szVar = Substr( requestOptions, iPos, iLength [ [, iOffsetOrOccurence [, substrOptions] ] | [ strOffset [, substrOptions ] ] ] );

result = Substr(input_string, strLeft, strRight [ [, iOffset [, substrOptions] ] | [ strOffset [, substrOptions ] ] ] );
result = Substr(input_string, iPos, strRight [ [, iOffset [, substrOptions] ] | [ strOffset [, substrOptions ] ] ] );
result = Substr(input_string, strLeft, iLength [ [, iOffset [, substrOptions] ] | [ strOffset [, substrOptions ] ] ] );
result = Substr(input_string, iPos, iLength [ [, iOffset [, substrOptions] ] | [ strOffset [, substrOptions ] ] ] );

Parameter:

requestOptions

Available options are:

CONTENT  The function is applied on the current HTTP response 

strLeft

A string expression identifying the characters at the beginning of the substring.

strRight

A string expression identifying the characters at the end of the substring.

iPos

An integer expression identifying the starting position of the desired substring.

iLength

An integer expression identifying the number of characters to include in the returned substring.

iOffsetOrOccurence

integer expression: If the OCCURENCE option is set in the substrOptions flag, iOffsetOrOccurence identifies the occurence of the substring to be found. If not, it is the index of the position at which the search is to begin.

strOffset

string expression: starts the searching from the position of the first occurence of the strOffset character string.

input_string

A string expression on which the function is applied.

substrOptions (optional)

Available options are:

NOCASE  Performs a case insensitive search 
EXCLUDE  By default, any delimiter strings specified (strLeft and strRight) are included in the returned substring.
 Both delimiters may be excluded from the returned substring by specifying the EXCLUDE option.
 When EXCLUDE option is set, the search begin after the optional strOffset parmeter
REGEXP  String delimiters (strLeft and strRight) are treated as regular expressions
OFFSET  The iOffsetOrOccurence paramater identifies the index of the character in the string to begin the search with, or 0 to start from the beginning. The strOffset parameter identifies the character string to begin the search with.
OFFSET_REVERSE  The iOffsetOrOccurence paramater identifies the index of the character from the end in the string to begin the search with. The strOffset parameter identifies the character string from the end to begin the search with.
OCCURENCE  The iOffsetOrOccurence paramater identifies the occurence of the substring to be found.
OCCURENCE_REVERSE  The iOffsetOrOccurence paramater identifies the occurence of the substring to be found. Occurrence count starts from the end.
RANDOM  The iOffsetOrOccurence is ignored. A random instance of the the substring to be found is extracted.

Example:

string szVar;

// Extract 12 characters beginning at position 20 from HTML page
HTTP GET HOST "demo.fmstocks.com" URL "/fmstocks/home.asp" szVar = Substr(content, 20, 12);

// Extract a substring delimited by "Welcome" and "FMStocks" from HTML page
HTTP GET HOST "demo.fmstocks.com" URL "/fmstocks/home.asp" szVar = Substr(content, "Welcome", "FMStocks");

// Extract the 3rd substring delimited by "Welcome" and "FMStocks" from HTML page
HTTP GET HOST "demo.fmstocks.com" URL "/fmstocks/home.asp" szVar = Substr(content, "Welcome", "FMStocks", 3, OCCURENCE);

// Extract 12 characters beginning at position where "Welcome" is found into szInputHTML variable
szVar = Substr(szInputHTML, "Welcome", 12);

// Extract a substring beginning at position 20 and until "FMStocks" is found into szInputHTML variable
szVar = Substr(szInputHTML, 20, "FMStocks");

// Start at offset 30, extract a substring delimited by "Welcome" and "FMStocks", exclude those delimiters from the returned string
szVar = Substr(content, "Welcome", "FMStocks", 30, EXCLUDE);

// Extract a random occurence of the substring delimited by the "Welcome" and "FMStocks" character string from HTML page
HTTP GET HOST "demo.fmstocks.com" URL "/fmstocks/home.asp" szVar = Substr(content, "Welcome", "FMStocks", 0, RANDOM);
 

See also:





Go back to the Learning center:


Copyright © AgileLoad. All rights reserved.
Agile Load testing tool| Contact AgileLoad | Terms of Use | Sitemap