Strspn Function

Action

Searches in sString for the first character that does not belong to the set of characters in sCharacterSet.

Include file

Kernel.bdh

Syntax

Strspn( in sString       : string,
        in sCharacterSet : string ): number;

Return value

Index of the first character in sString that does not belong to the set of characters in sCharacterSet. If sString begins with a character not in sCharacterSet, the function returns 1.

Parameter Description
sString Defines the string to search in
sCharacterSet Defines a set of character as a search criteria

Example

dcltrans
  transaction TStrspn
  var
    sString, sSet : string;
    nIndex        : number;
  begin
    sString := "Hello world!";
    sSet    := "ABCDEFGHabcdefgh";
    write("string = "); write(sString); writeln;
    write("set    = "); write(sSet); writeln;

    nIndex := Strspn(sString, sSet);
    write("index  = "); write(nIndex); writeln;
  end TStrspn;

Output

string = Hello world!
set    = ABCDEFGHabcdefgh
index  = 3