EXTRACT$
<< Click to Display Table of Contents >> Navigation: ThinBASIC Core Language > BuiltIn Functions > String functions > EXTRACT$ |
Description
Return the portion of a string leading up to the first occurrence of a specified character or string.
Syntax
s = EXTRACT$([Start,] MainString, [ANY] MatchString [, CaseSensitive])
Returns
String
Parameters
Name |
Type |
Optional |
Meaning |
Start |
Number |
Yes |
Optional starting position in MainString |
MainString |
String |
No |
String to search in |
MatchString |
String |
No |
String to search for. |
CaseSensitive |
Number |
Yes |
Optional parameter used to indicate if match must be case sensitive or not. Use %TRUE or %FALSE. Default value is %TRUE |
Remarks
If the ANY keyword is specified, MatchString specifies a list of single characters to be searched for individually.
Restrictions
See also
Examples
Script example
' FirstItem = first command-line argument, assuming
' spaces, commas, periods, and tabs are valid delimiters
FirstItem = EXTRACT$(COMMAND$, ANY " ,." + CHR$(9))
Thanks to Michael Clease for the following script example
' Usage of the EXTRACT$ Keyword example'
' Written by Michael Clease
Dim sMainString As String Value "The quick brown fox jumped over the lazy dogs"
Dim sMatchString As String Value "over"
Dim sExtractString As String
DIM Start as DWORD VALUE 4
DIM sMsg as string
sExtractString = Extract$(Start,sMainString, sMatchString)
sMsg = "sMainString = " & sMainString & $CRLF
sMsg += "sMatchString = " & sMatchString & $CRLF
sMsg += "sExtractString = " & sExtractString & $CRLF & $CRLF
MsgBox 0, sMsg