<<

Contents

Search

>>

 

SUBSTR$

 

 

Function

 

 

Syntax:

SUBSTR$(<String>,<Separator>,<Number of Substring>)

 

<String>

= <STRING-EXPRESSION>

<Separator>

= <STRING-EXPRESSION>

<Number of Substring>

= <NUM-EXPRESSION>

 

 

Meaning:

Returns a substring from a string which has separators.

 

<Separator> divides the <String> into several substrings. SUBSTR$ returns the substring number <Number of Substring>.

 

If <Number of Substring> <= 0, the first substring is returned.

 

Parameter:

String

String expression

Separator

Separator can contain more than 1 character.

Number of Substring

Number of substring

 

Sample:

H$ = "AAA;BBB;ccc"

SEP$ = ";"

S0$ = SUBSTR$(H$,SEP$,0) /* S0$ contains "AAA"

S1$ = SUBSTR$(H$,SEP$,1) /* S1$ contains "AAA"

S2$ = SUBSTR$(H$,SEP$,2) /* S2$ contains "BBB"

S3$ = SUBSTR$(H$,SEP$,3) /* S3$ contains "CCC"

S4$ = SUBSTR$(H$,SEP$,4) /* S4$ contains ""

 

H$ = "Hello"

S1$ = SUBSTR$(H$,";",1)  /* S1$ contains "Hello"

S2$ = SUBSTR$(H$,";",2)  /* S2$ contains ""

 

H$ = "Test1;;Test2;"

S1$ = SUBSTR$(H$,";;",1) /* S1$ contains "Test1"

S2$ = SUBSTR$(H$,";;",2) /* S2$ contains "Test2;"

 

See also:

DELSUBSTR$

REPLSTR$

INSTR

INSTR_COUNT

STRSEP$