SpiceInt ncpos_c ( ConstSpiceChar * str,
ConstSpiceChar * chars,
SpiceInt start )
Find the first occurrence in a string of a character NOT belonging
to a collection of characters, starting at a specified location,
searching forward.
SCANNING
CHARACTER
SEARCH
UTILITY
VARIABLE I/O DESCRIPTION
-------- --- --------------------------------------------------
str I Any character string.
chars I A collection of characters.
start I Position to begin looking for one not in chars.
The function returns the index of the first character of str
at or following index start that is not in the collection chars.
str is any character string.
chars is a character string containing a collection of
characters. Spaces in chars are significant, including
trailing blanks. The order in which characters are
listed is not significant.
start is the position in str to begin looking for characters
not in chars. start may range from 0 to n-1, where n is
the number of characters in str.
The function returns the index of the first character of str (at or
following index start) that is not one of the characters in the
string chars. The returned value normally ranges from 0 to n-1,
where n is the number of characters in str. If no such character is
found, the function returns -1.
None.
1) The error SPICE(NULLPOINTER) is signaled if either of
the input string pointers is null.
2) If start is less than 0, the search begins at the first
character of the string.
3) If start is greater than or equal to the length of the string,
ncpos_c returns -1.
4) The function returns -1 if either of the input strings is empty.
None.
ncpos_c is case sensitive.
An entire family of related CSPICE routines
cpos_c
cposr_c
ncpos_c
ncposr_c
pos_c
posr_c
is described in the Required Reading.
Let string == "BOB, JOHN, TED, AND MARTIN "
012345678901234567890123456789
Let chars == "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
Normal (Sequential) Searching:
------------------------------
ncpos_c( string, chars, 0 ) == 3
ncpos_c( string, chars, 4 ) == 4
ncpos_c( string, chars, 5 ) == 9
ncpos_c( string, chars, 10 ) == 10
ncpos_c( string, chars, 11 ) == 14
ncpos_c( string, chars, 15 ) == 15
ncpos_c( string, chars, 16 ) == 19
ncpos_c( string, chars, 20 ) == 26
ncpos_c( string, chars, 27 ) == 27
ncpos_c( string, chars, 28 ) == 28
ncpos_c( string, chars, 29 ) == 29
start out of bounds:
--------------------
ncpos_c( string, chars, -12 ) == 3
ncpos_c( string, chars, -1 ) == 3
ncpos_c( string, chars, 30 ) == -1
ncpos_c( string, chars, 122 ) == -1
None.
None.
N.J. Bachman (JPL)
W.L. Taber (JPL)
-CSPICE Version 1.0.0, 14-AUG-2002 (NJB) (WLT)
forward search for position of unlisted character
Link to routine ncpos_c source file ncpos_c.c
|