Siebel eScript Language Reference > Siebel eScript Commands > The Clib Object String Methods >

Clib.strspn() Method

This method searches a string for characters that are not among a group of specified characters.


Clib.strspn(string, charSet)



A literal string, or a variable containing a string, to be searched


A literal string, or a variable containing a string, which contains the set of characters to search for


If all matching characters are found, the length of the string; otherwise, the offset of the first character in string that is not a member of charSet.


This method searches the characters from the beginning of string, then returns the offset of the first character that is not a member of charSet. The search is case sensitive, so you may have to include both uppercase and lowercase instances of characters in charSet.

This method is similar to Clib.strpbrk(), except that Clib.strpbrk() returns the string beginning at the first character found, while Clib.strspn() returns the offset number for that character.

When possible, you should use the standard JavaScript method substring() (see String replace() Method).


The following fragment demonstrates Clib.strspn(). When searching string, it returns the position of the w, counting from 0.

var string = "There is more than one way to swim.";
var rStrspn = Clib.strspn(string, " aeiouTthrsmn");
TheApplication().RaiseErrorText("strspn returns an integer: " + rStrspn);

This results in the following output:

strspn returns an integer: 23

See Also

Clib.strchr() Method
Clib.strcspn() Method
Clib.strpbrk() Method
String replace() Method

Siebel eScript Language Reference