Introduction

Overview / Layout

Panels

FileSystem

File Operations

Extensions

Tools

Customization and Configuration

Configuring the Layout

User Commands and Scripting

Other

API

Troubleshooting

FAQ (pages to follow)

Index

MultiScript - String Functions

The following string functions are supported in MultiScript:

StrLen Return the length of a string.
StrSub Return a substring from a string.
StrFind Return the position of a substring in a string.
StrRFind Return the position of a substring using reverse find (back-to-front search).
StrReplace Replace a substring in a string.
StrReplaceChars Replace all characters found with one new character.
StrReplaceCharsPairs Replace all characters found with a new characters.
StrToUpper Return a string in uppercase.
StrToLower Return a string in lowercase.
StrTrim Return a string that has been trimmed of unwanted characters both at the beginning and end.
StrTrimLeft Return a string that has been trimmed of unwanted characters from the left.
StrTrimRight Return a string that has been trimmed of unwanted characters from the right.
StrSplit Split a string and return the separated substrings as an array.
StrSplitAnyOf Split a string on any delimiter it finds and return the separated substrings as an array.
StrCompareNoCase Return the difference of two strings ignoring case differences.
operator == Return the difference of two strings (case-sensitive comparison).
StrIsEqual Return 1 if two strings are equal, otherwise 0 (case-sensitive).
StrIsEqualNoCase Return 1 if two strings are equal, ignoring case differences.
StrIsWildMatch Return 1 if two strings match using a case-sensitive wildcard algorithm.
StrIsWildMatchNoCase Return 1 if two strings match using a case-insensitive wildcard algorithm.
StrIsRegExpMatch Return 1 if two strings match using regular expressions (case-sensitive).
StrIsRegExpMatchNoCase Return 1 if two strings match using regular expressions, ignoring case difference.
StrRegExpFind Find a substring using a regular expression.
StrRegExpReplace Find a substring using a regular expression and replace it using regexp.

See also

SaveStringToFile
LoadStringFromFile

StrLen

Return the length of a string.

<num> StrLen( <str> string );

Parameters

string
A string to get the length of

Return Value

The number of characters in string

Example

@var $str = "MyString";
@var $len = StrLen( $str );
// $len is 8

StrSub

Return a substring beginning at a specified location and having a specified length

<str> StrSub(<str> input, <num> offset, <num> length);

Parameters

input
A string from which the substring is extracted
offset
Initial position to begin the search (starting with 0)
length
The number of characters to include in the returned substring, or -1 to include all characters through to the end of the string input

Return Value

A string that is the substring of input beginning at the specified location

StrFind

Find the position of a substring in a string (case-sensitive).

<num> StrFind(<str> input, <str> find, <num> offset);

Parameters

input
The string to be searched
find
The string to be found
offset
Initial position to begin the search (starting with 0)

Return Value

The position in the input string in which the search string find is found (the first character position is 0), or -1 if find is not found

StrRFind

Find the position of a substring in a string, searching the string in reverse (case-sensitive).

<num> StrRFind(<str> input, <str> find);

Parameters

input
The string to be searched
find
The string to be found

Return Value

The position in the input string in which the search string find is found (the first character position is 0), or -1 if find is not found

StrReplace

Replace a substring within a string (case-sensitive).

<str> StrReplace(<str> input, <str> find, <str> with );

Parameters

input
A string within which to replace the substring
find
The substring to be replaced
with
The string that the substring find should to be replaced with

Return Value

The string input with the substring find replaced by the string with

Example

@var $str = "MyString";
@var $str2 = StrReplace( $str, "My" , "New" );
// $str2 is "NewString"

StrReplaceChars

Replace a any specified character with one new character (case-sensitive).

<str> StrReplaceChars(<str> input, <str> find, <str> with );

Parameters

input
A string within which to replace the substring
find
A string of character to find
with
The character that any of the found characters should be replaced with

Return Value

The string input with the characters replaced, If any. If no characters was replace the string is returned unmodified

Example

@var $str = "MyString";
@var $str2 = StrReplaceChars( $str, "ryg" , "_" );
// $str2 is "M_St_in_"

StrReplaceCharsPairs

Replace a any specified character with a matching characters (case-sensitive).
the find and with parameter must be same in length. Ex character 2 in "find" will when found be replaced with character 2 from "with"

<str> StrReplaceCharsPairs(<str> input, <str> find, <str> with );

Parameters

input
A string within which to replace the substring
find
A string of character to find
with
The string of characters to replace a found character with

Return Value

The string input with the characters replaced, If any. If no characters was replace the string is returned unmodified

Example

@var $str = "MyString";
@var $str2 = StrReplaceChars( $str, "ryg" , "_23" );
// $str2 is "M2St_in3"

StrToUpper

Transform a string into all uppercase characters.

<str> StrToUpper(<str> input);

Parameters

input
A string that should be transformed

Return Value

An uppercase version of the string input

StrToLower

Transform a string into all lowercase characters.

<str> StrToLower(<str> input);

Parameters

input
A string that should be transformed

Return Value

A lowercase version of the string input

StrTrim

Remove unwanted characters from both the left and right side of a string (case-sensitive).

<str> StrTrim(<str> input, <str> trimchars);

Parameters

input
A string that should be trimmed
trimchars
A string specifying all characters to be removed

Return Value

A string where all characters in trimchars have been removed from both the left side (beginning) and the right side (end) of the string input

StrTrimLeft

Remove unwanted characters from the left side of a string (case-sensitive).

<str> StrTrimLeft(<str> input, <str> trimchars);

Parameters

input
A string that should be trimmed
trimchars
A string specifying all characters to be removed

Return Value

A string in which all characters in trimchars have been removed from the left side (beginning)

StrTrimRight

Remove unwanted characters from the right side of a string (case-sensitive).

<str> StrTrimRight(<str> input, <str> trimchars);

Parameters

input
A string that should be trimmed
trimchars
A string specifying all characters to be removed

Return Value

A string in which all characters in trimchars have been removed from the right side (end)

StrSplit

Split a string into an array of strings (case-sensitive).

<array> StrSplit(<str> input, <str> delimiter);

Parameters

input
A string that should be split
delimiter
A string containing the character(s) that will be used as a delimiter

Return Value

The string input split into multiple strings in an array of type string. The string is split wherever the character(s) in the string delimiter are located

If the characters in delimiter are not found, the original string input is returned

StrSplitAnyOf

Split a string on any of the delimiters into an array of strings (case-sensitive).

<array> StrSplitAnyOf(<str> input, <str> delimiters);

Parameters

input
A string that should be split
delimiters
A string containing the characters that will be used as a delimiter. It will split on ANY of the specified characters

Return Value

The string input split into multiple strings in an array of type string. The string is split wherever any of the character(s) in the string delimiter are located

If the characters in delimiter are not found, the original string input is returned

StrCompareNoCase

Compare two strings, ignoring case differences.

<num> StrCompareNoCase(<str> string1, <str> string2);

Parameters

string1
First string to compare
string2
Second string to compare

Return Value

A number showing the differences between the strings string1 and string2. The return value indicates the lexicographic relation of string1 to string2

< 0 if string1 is less than string2.
0 if string1 is equal to string2.
> 0 if string1 is greater than string2.

Operator ==

Compare two strings (case-sensitive).

<num> <str> == <str>;

Parameters

string1
First string to compare
string2
Second string to compare

Return Value

1 if the string are the same, and 0 if the are different.

Example

@var $str1 = "ABCDEF";
@var $str2 = "ABCDEF";
@var $val = $Str1 == $Str2;
// $val == 1
@var $str3 = "AbcDeF";
@var $val = $Str2 == $Str3;
// $val == 0

StrIsEqual

Check whether two strings are equal (case-sensitive).

<num> StrIsEqual(<str> string1, <str> string2);

Parameters

string1
First string to compare
string2
Second string to compare

Return Value

A value of 1 if string1 is equal to string2, 0 if the strings are not identical

StrIsEqualNoCase

Check whether two strings are Equal, ignoring case differences.

<num> StrIsEqualNoCase(<str> string1, <str> string2);

Parameters

string1
First string to compare
string2
Second string to compare

Return Value

A value of 1 if string1 is equal to string2, 0 if the strings are not identical (ignoring case)

StrIsWildMatch

Check if a string matches a wildcard criterion (case-sensitive).
Wildcard is a string containing "*" (for anything) and "?" (for any single character).

<num> StrIsWildMatch(<str> input, <str> wildcard);

Parameters

input
A string to check
wildcard
A wildcard string to check against

Return Value

1 if wildcard matches the string input, 0 if no match is found

Examples

@var $str = "123def567";
// If the character sequence "def" is in the string $str, $val1 will be 1
@var $val1 = StrIsWildMatch( $str , "*def*");

// The two first characters can be anything,
// But the third character must be a 3.
// And anything can be after it. then $val1 will be 1
@var $val1 = StrIsWildMatch( $str , "??3*"); 

StrIsWildMatchNoCase

Check if a string matches wildcard criteria, ignoring case differences.
Wildcard is a string containing "*" (for anything) and "?" (for any single character).

<num> StrIsWildMatchNoCase(<str> input, <str> wildcard);

Parameters

input
A string to check
wildcard
A wildcard string to check against

Return Value

1 if wildcard matches the string input, 0 if no match is found

StrIsRegExpMatch

Check if a string matches a regular expression (case-sensitive).

<num> StrIsRegExpMatch(<str> input, <str> regexp);

Parameters

input
A string to check
regexp
A regular expression to check against

Return Value

1 if the regular expression regexp matches the string input, 0 if no match is found

StrIsRegExpMatchNoCase

Check if a string matches a regular expression, ignoring case differences.

<num> StrIsRegExpMatchNoCase(<str> input, <str> regexp);

Parameters

input
A string to check
regexp
A regular expression to check against

Return Value

1 if the regular expression regexp matches the string input, 0 if no match is found

StrRegExpFind

Find a substring using a regular expression.

<num> StrRegExpFind(<str> input, <str> regexp);

Parameters

input
String to find a substring in
regexp
Regular expression to find the substring

Return Value

Position in the string input where a match was found, or -1 if no match is found

Example

@var $str = "Program v3.10";
@var $len = StrRegExpFind( $str , ".v[0-9].[0-9][0-9]" );
// $len is 7