ExtractBetween$

String management function.

The ExtractBetween$ function extracts a string between two strings.

Usage

Used to extract a string 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$(<initial_string>,<start_string>,included|excluded,<end_string$>,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 successfull 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"