String Utilities

StrIns

Purpose:

Insert characters into a string.

Category:

Strings

Syntax:

StrIns "source string" "dest string" "insert position" "variable"

source string

The characters to be inserted.

dest string

The destination string.

insert position

The position in dest string where the characters will be inserted.

variable

The name of a variable to store the modified string.

Example:

The following example will insert the contents of the variable [Name] into a string and store the result in a variable called [Greeting]:


StrIns "[Name]" "Hello . How are you?" "7" "[Greeting]"


StrDel

Purpose:

Delete characters from a string.

Category:

Strings

Syntax:

StrDel "source string" "start position" "length" "variable"

source string

The original string containing the characters to delete.

start position

The position of the first character to delete.

length

The number of characters to delete.

variable

The name of a variable to store the modified string.

Example:

The example below searches for spaces in the string assigned to the variable [Name] and if found removes all characters that follow. The modified string is placed back into the [Name] variable:


SearchStr " " "[Name]" "[SpacePos]"
If "[SpacePos]" ">" "0"
  Strlen "[Name]" "[Len]"
  StrDel "[Name]" "[SpacePos]" "[Len]-[SpacePos]+1" "[Name]"
EndIf


StrLen

Purpose:

Calculate the length of a string.

Category:

Strings

Syntax:

StrLen "string" "variable"

string

The string to examine.

variable

The name of a variable to store the string’s length.

Example:

In the example below, the variable [Name] contains the string "Bernard". Since this string contains seven characters, the example Action will place “7” into the variable [Size]:


StrLen "[Name]" "[Size]"


SubStr

Purpose:

Copy a portion of a string.

Category:

Strings

Syntax:

SubStr "source string" "start position" "length" "variable"

source string

The original string containing the characters to copy.

start position

The position of the first character to copy.

length

The number of characters to copy.

variable

The name of a variable to store the copied text.

Example:

The example below, copies this president’s middle name (Quincy) into a variable called [MiddleName]:


SubStr "John Quincy Adams" "6" "6" "[MiddleName]"


SearchStr

Purpose:

Search for characters within a text string.

Category:

Strings

Syntax:

SearchStr "search for" "string" "variable" "options"

search for

The characters to find.

string

The text string to search.

variable

The name of a variable to store the position of the found characters. The variable will contain 0 (zero) if the characters are not present in the string.

options

Enter "CaseSensitive" here to search using the exact characters entered. Leave this parameter blank to perform a case insensitive search (upper and lower case characters are treated the same).

Example:

The following example searches for and removes all spaces from the variable  [Name]:


SearchStr " " "[Name]" "[SpacePos]"
While "[SpacePos]" ">" "0"
  StrDel "[Name]" "[SpacePos]" "1" "[Name]"
  SearchStr " " "[Name]" "[SpacePos]" ""
EndWhile


StrUpper

Purpose:

Convert the contents of a string to upper case. Numbers and punctuation within the string are not affected.

Category:

Strings

Syntax:

StrUpper "string" "variable"

string

The string to convert.

variable

The name of a variable to store the modified string.

Example:

StrUpper "good dog" "[Result]"


StrLower

Purpose:

Convert the contents of a string to lower case. Numbers and punctuation within the string are not affected.

Category:

Strings

Syntax:

StrLower "string" "variable"

string

The string to convert.

variable

The name of a variable to store the modified string.

Example:

StrLower "GOOD DOG" "[Result]"


StrReplace

Purpose:

Replace all occurrences of a character or substring within a string.

Category:

Strings

Syntax:

StrReplace "string" "old chars" "new chars" "variable" "options"

string

The original string.

old chars

The characters to replace.

new chars

The replacement characters.

variable

The name of a variable to store the modified string.

options

Enter "CaseSensitive" here to search using the exact characters entered. Leave this parameter blank to perform a case insensitive search (upper and lower case characters are treated the same).

Example:

The following example replaces each occurrence of the word "dog" in the source string with "cat":


StrReplace "My dog is a good dog." "dog" "cat" "[Result]" ""


You can also use this Action to remove a character by leaving the replacement characters parameter empty. For example:


StrReplace "My doggy is a good doggy." "gy" "" "[Result]" ""


StrParse

Purpose:

Separate a string into multiple parts using a delimiter character.

Category:

Strings

Syntax:

StrParse "source string" "delimiter" "array variable" "count variable"

source string

The string containing the information to parse.

delimiter

The character (or characters) used to separate the elements of the string.

array variable

The name of the variable array to store the parsed elements.

count variable

The name of a variable to store the number of elements stored in the array.


Each element in the string must be separated by the delimiter character (semicolon, comma, hyphen, etc.). StrParse will use the delimiter to divide the source string into individual elements which are placed into an array based on the array variable. The count variable will be set to the number of elements stored in the array.

Example:

The example below takes a list of file names from the FileOpenBox Action and separates them into individual files:


FileOpenBox "Open" "Any File|*.*" "c:\" "[Files]" "Multiple"
StrParse "[Files]" ";" "[Names]" "[Count]"


When executed, an array based on the [Names] variable ([Names1], [Names2], etc.) will be created. Each element in the array will contain one file name. The number of elements in the array ([Count]) will be equal to the number of files selected.


PopulateStr

Purpose:

Populate variables contained within a string. VisualNEO Win populates most strings automatically. The exception being strings that come from an external source such as a file loaded with the FileRead or FileToVar actions. After reading, if the file contained VisualNEO Win style variables, you can use PopulateStr to replace all of the variables in the string with the contents of those variables.

Category:

Strings

Syntax:

PopulateStr "string" "variable"

string

The source string containing variables to populate.

variable

The name of a variable to store the modified string.

Example:

FileToVar "[PubDir]sample.html" "[RawHTML]"

PopulateStr "[RawHTML]" "[PopulatedHTML]"

BrowserLoadFromStr "WebBrowser1" "[PopulatedHTML]"


Regex String Utilities


Reference:

https://regex.sorokin.engineer/en/latest/index.html


Info:

https://www.regular-expressions.info/


Online tools:

https://regex101.com/

https://www.regextester.com/



StrRegexIsMatch

Purpose:

Execute a regular expression and return True/False .

Category:

Strings

Syntax:

StrRegexIsMatch "regular expression" "string" "variable"

regular expression

   Regular expression string or variable
string

String or variable with the string to process.

variable

Store the result in this variable.

Example:

SetVar "[RegExStr]" "^\s*\d{3}-(\d{2}-\d{2}|\d{4})\s*$"

StrRegExIsMatch "[RegExStr]" "[ComboBox2]" "[PhoneValid_Result]"


StrRegexList

Purpose:

Execute a regular expression and return a list 

Category:

Strings

Syntax:

StrRegexList "regular expression" "string list" "delimiter" "variable"

regular expression

   Regular expression string or variable

string list

   String-list or variable with the string-list to process.
delimiter

Delimiter of the result list.

variable

Variable for result-list.

Example:

StrRegexList "[RegExStr]" "[PubDir]RegExStr.txt" "[#13][#10]" "[Result]"


StrRegexPos

Purpose:

Execute a regular expression and return a list with Pos and Length of found-pos

Category:

Strings

Syntax:

StrRegexPos "regular expression" "string" "variable"

regular expression

   Regular expression string or variable
string

String or variable with the string to process.

variable

Variable for post-list (pairs of pos - lenght).

Example:

StrRegexPos "[RegExStr]" "[PubDir]RegExStr.txt" "[Email_Result]"


StrRegexSplit

Purpose:

Split a string with a regular expression

Category:

Strings

Syntax:

StrRegexSplit "regular expression" "string list" "delimiter" "variable"

regular expression

   Regular expression string or variable

string list

   String-list or variable with the string-list to split.

delimiter

Delimiter of the result list.

variable

Variable for result-list.

Example:

StrRegExSplit "[RegExStr]" "[TextEntry]" "[#13][#10]" "[Split_Result]"


StrRegexReplace

Purpose:

Replacing with regular expressions 

Category:

Strings

Syntax:

StrRegexReplace "regular expression" "string" "string" "flag" "variable"

regular expression

   Regular expression string or variable to search

string

   String or variable to replace in.

string

   String or variable to replace with.

flag

   Flag for substitution (True / False)

variable

Variable for result-string.

Example:

StrRegexReplace "[ReplaceWhat]" "[ReplaceText]" "[ReplaceWith]" "True" "[Replace_Result]"


StrRegexSubstitute

Purpose:

Substitute in a string-template with regular expressions

Category:

Strings

Syntax:

StrRegexSubstitute "regular expression" "string" "template string" "variable"

regular expression

   Regular expression string or variable to search.

string

   String or variable with string-list to substitute.

template string

   Template string to be substituted.

variable

Variable for result-string based on processed template

Example:

StrRegexSubstitute "[RegExStr]" "[SearchPhoneText]" "[TemplateText]" "[Substitute_Result]"


Hash Utilities


HashString

Purpose:

Get several different Hash-string from a string.

Hashing is the process of transforming any given key or a string of characters into another value. This is usually represented by a shorter, fixed-length value or key that represents and makes it easier to find or employ the original string.
Hashing is relevant to, but not limited to, data indexing and retrieval, digital signatures, cybersecurity and cryptography. 

Category:

Strings

Syntax:

HashString "type" "string" "variable"

type

   Hash type. One of the following:

   MD5

   SHA256

   SHA512

string

Source string.

variable

The name of a variable to store the Hash-string.

Example:

HashString "SHA512" "This is a text" "[Result]"


HashFile

Purpose:

Get several different Hash-string from a file or stream.

Hashing is an algorithm that calculates a fixed-size bit string value from a file. A file basically contains blocks of data. Hashing transforms this data into a far shorter fixed-length value or key which represents the original string. The hash value can be considered the distilled summary of everything within that file.

Category:

Strings

Syntax:

HashFile "type" "file" "variable"

type

   Hash type. One of the following:

   MD5

   SHA256

   SHA512

file

Source file.

variable

The name of a variable to store the Hash-string.

Example:

HashFile "SHA512" "c:\myfolder\myfile.txt" "[Result]"


GUID 

Purpose:

Get a GUID.

GUID technically stands for globally unique identifier. What it is, actually, is a 128 bit structure that is unlikely to ever repeat or create a collision. Use guids when you have multiple independent systems or clients generating ID's that need to be unique.

For example, if I have 5 client apps creating and inserting transactional data into a table that has a unique constraint on the ID, then use guids. This prevents having to force a client to request an issued ID from the server first.

Category:

Strings

Syntax:

GUID "variable"

variable

The name of a variable to store the GUID.

Example:

GUID "[Result]"