EXTRACT$ function

Purpose:

If a case-sensitive Match$ is found in MainStr$, EXTRACT$ gets all characters in MainStr$ up to the beginning of the first instance of Match$. The BCX EXTRACT$ function complements the REMAIN$ function.

Syntax:

SubStr = EXTRACT$(MainStr AS STRING, Match AS STRING)

Return Value:

  • Data type: STRING
    SubStr All characters in MainStr up to the beginning of the first instance of Match. EXTRACT$ returns MainStr when a match is not found.

Parameters:

  • Data type: STRING
    MainStr String from which substring is to be extracted.
  • Data type: STRING
    Match SubString to be located in MainStr.

Example:

DIM SubStr$

SubStr$ = EXTRACT$("Filename.bas", ".bas")

PRINT SubStr$

Result:

Filename

BCX Console Sample Programs using the EXTRACT$ function.

EXTRACTANY$ function

Purpose:

If a case-sensitive instance of any character in Match is found in MainStr, EXTRACTANY$ gets all characters in MainStr up to the beginning of the first instance of any character in Match.

Syntax:

SubStr = EXTRACTANY$(MainStr AS STRING, Match AS STRING)

Return Value:

  • Data type: STRING
    SubStr All characters in MainStr up to the beginning of the first instance of any character in Match. EXTRACTANY$ returns MainStr when a match is not found.

Parameters:

  • Data type: STRING
    MainStr String from which substring is to be extracted.
  • Data type: STRING
    Match String of characters, any of which are to be located in MainStr.

Example:

DIM SubStr$

SubStr$ = EXTRACTANY$("Bond, James Bond", " ,")

PRINT SubStr$

SubStr$ = EXTRACTANY$(SubStr$, " ,")

PRINT SubStr$

Result:

Bond
Bond

REMAIN$ function

Purpose:

If a case-sensitive Match$ is found in MainStr$, REMAIN$ gets all characters in MainStr$ from the end of the first instance of Match$. The BCX REMAIN$ function complements the EXTRACT$ function

Syntax:

SubStr = REMAIN$(MainStr AS STRING, Match AS STRING)

Return Value:

  • Data type: STRING
    SubStr All characters in MainStr from the end of the first instance of Match. REMAIN$ returns MainStr when a match is not found.

Parameters:

  • Data type: STRING
    MainStr String to be searched and parsed.
  • Data type: STRING
    Match SubString to be located in MainStr.

Example:

DIM SubStr$

SubStr$ = REMAIN$("Filename.bas", "name")

PRINT SubStr$

Result:

.bas