ExtractBetween$ – String Management Function**





ExtractBetween$ Function


Description

The ExtractBetween$ function extracts a string between two specified strings.

Usage

Used to extract a substring from a long captured string. You can capture data from a window or a web page using the Capture wizard (menu Start/Capture wizard) and take from the captured data only a part of it.

Syntax

var$ = ExtractBetween$(, , included|excluded, , included|excluded)

Parameters

<initial_string>: string from which extraction is done.

<start_string>: string where the extraction starts. The extracted result includes the <start_string> if the keyword Included is specified; it excludes it if the keyword Excluded is specified. If <start_string> is an empty string ("") or is not found, the extraction starts from the beginning of <initial_string>.

<end_string>: string where the extraction finishes. The extracted result includes the <end_string> if the keyword Included is specified; it excludes it if the keyword Excluded is specified. If <end_string> is an empty string ("") or is not found, the extraction goes to the end of <initial_string>.

Note that the extraction process is case-sensitive. The extraction is done between the first occurrence of <start_string> and the first occurrence of <end_string>.

If <start_string> and <end_string> are the same, the extracted result is the string between the first and the second occurrence of <start_string>.

Return Value

var$ returns the extracted string. If the extraction is not successful for any reason, var$ is empty (an empty string is "").

See Also

Extract name, directory and extension from a full filename.

Examples


Initialstring$ = "Automate any combination of tasks, whether Web or Windows applications"
Startstring$ = "any"
Endstring$ = "Web"
a$ = ExtractBetween$(Initialstring$, Startstring$, included, Endstring$, included)
' a$ contains: "any combination of tasks, whether Web"

a$ = ExtractBetween$(Initialstring$, Startstring$, included, Endstring$, excluded)
' a$ contains: "any combination of tasks, whether"

a$ = ExtractBetween$(Initialstring$, Startstring$, excluded, Endstring$, included)
' a$ contains: " combination of tasks, whether Web"

Initialstring$ = "Automate any combination of tasks, whether Web or Windows applications"
Startstring$ = ""
Endstring$ = "Web"
a$ = ExtractBetween$(Initialstring$, Startstring$, included, Endstring$, included)
' a$ contains: "Automate any combination of tasks, whether Web"

Initialstring$ = "Automate any combination of tasks, whether Web or Windows applications"
Startstring$ = "any"
Endstring$ = "nothing"
a$ = ExtractBetween$(Initialstring$, Startstring$, included, Endstring$, included)
' a$ contains: "any combination of tasks, whether Web or Windows applications"

' Some examples at boundaries
a$ = ExtractBetween$("abc def ghi £test abc >test", "£", included, "£test", included)
' a$ contains: "£test abc >test"

a$ = ExtractBetween$("abcabctt", "abc", excluded, "abc", included)
' a$ contains: "abc"

a$ = ExtractBetween$("abcabctt", "", excluded, "abc", excluded)
' a$ contains: "" (empty string)

a$ = ExtractBetween$("ttabcabc uu", "abc", excluded, "", excluded)
' a$ contains: "abc uu"