Searches in sString for the first occurrence of one character belonging to a defined set of characters in a string.
Kernel.bdh
Strcspn( in sString : string, in sCharacterSet : string ): number;
Index of the first character in sString that belongs to the set of characters in sCharacterSet. If sString begins with a character in sCharacterSet, the function returns 1. If none of the characters in sString is in sCharacterSet, the function returns 0.
Parameter | Description |
---|---|
sString | Specifies the string to search in |
sCharacterSet | Specifies the set of characters in a string |
dcltrans transaction TStrcspn var sString, sSet : string; nPos : number; begin sString := "Hello world!"; sSet := "awx_?"; write("string = "); write(sString); writeln; write("set = "); write(sSet); writeln; // search for the first occurrence of one of the characters nPos := Strcspn(sString, sSet); write("pos = "); write(nPos); writeln; end TStrcspn;
string = Hello world! set = awx_? pos = 7