Siebel eScript Language Reference > C Language Library Reference > Clib String Methods >

Clib Search String for Character Set Method


The Clib Search String for Character Set method searches a string for a set of characters that you specify in the charSet argument. It returns one of the following values:

  • If it finds this set, then it returns the offset of the first character of the first occurrence of the set that you specify in the charSet argument. This offset is the number of characters in the string from the beginning to the first occurrence, starting with 0.
  • If it does not find this set, then it returns the length of the string.
Format

Clib.strcspn(string, charSet)
Clib.strpbrk(string, charSet)

Clib.strcspn is similar to Clib.strpbrk, except that Clib.strpbrk returns the set that begins at the first character found while Clib.strcspn returns the offset number for that character.

Table 160 describes the arguments for the Clib Search String for Character Set method.

Table 160. Arguments for the Clib Search String for Character Set Method
Argument
Description

string

A literal string or a variable that contains the character set for which this method searches.

charSet

A literal string or a variable that is the character set for which this method searches.

Usage for the Clib Search String for Character Set Method

The Clib Search String for Character Set method searches for characters starting at the beginning of the string that you specify in the string argument. The search is case-sensitive, so you must use uppercase and lowercase characters in the charSet argument.

It is recommended that you use the Clib Search String for Character Set Method method only if you cannot use the equivalent standard JavaScript method.

Example

The following example demonstrates the difference between Clib.strcspn and Clib.strpbrk:

var string = "There's more than one way to climb a mountain.";
var rStrpbrk = Clib.strpbrk(string, "dxb8w9k!");
var rStrcspn = Clib.strcspn(string, "dxb8w9k!");
TheApplication().RaiseErrorText("The string is: " + string +
   "\nstrpbrk returns a string: " + rStrpbrk +
   "\nstrcspn returns an integer: " + rStrcspn);

This example provides the following results:

The string is: There's more than one way to climb a mountain.
strpbrk returns a string: way to climb a mountain.
strcspn returns an integer: 22

Siebel eScript Language Reference Copyright © 2013, Oracle and/or its affiliates. All rights reserved. Legal Notices.