beautypg.com

Findstr, Findstr, leftstr, rightstr – Visara Master Console Center Scripting Guide User Manual

Page 107

background image

Chapter 5 Script Commands

Scripting Guide

107

FINDSTR

Syntax:

FINDSTR( $String, $Substring) ==> $FoundText

Description:

Searches a string for a regular expression pattern.

Action:

$String is searched using the regular expression pattern $Substring.

The resultant substring found by the pattern $Substring is returned.

Parameters:

$String. String expression. The string to search for the pattern in.
$Substring. Regular expression. The regular expression pattern to
search for in $String. Refer to Regular Expressions on page 54 for

more information.

Returns:

String value, as follows:
Value

Meaning

“” (null string)

Matching substring not found

Any other value

The substring that matches the pattern $Substring.

Notes:

N/A

Example:

//Example 1
$Message := “The quick Brown Fox”
$Searchstr := “Brown”
$Result := FINDSTR( $Message, $Searchstr )
// The contents of $Result is “Brown”

//Example 2
$Message := “See Jane Run. Run Jane Run.”
$Searchstr := “Spot”
$Result := FINDSTR( $Message, $Searchstr )
// The contents of $Result is null (“”)

//Example 3
// Match a word beginning with “Test” and ending with 1
//or 3
$Message := “Test1 Test2 Test3”
$Searchstr := “Test[13]”
$Result := FINDSTR ($Message, $Searchstr )
// The contents of $Result is “Test1”

See Also:

ATSTR, LEFTSTR, RIGHTSTR, REPSTR, SUBSTR, STR