NCL Home > Documentation > Functions > Metadata routines

indStrSubset

Returns the indices corresponding to the location of the substring, if it is a subset of the other given string.

Available in version 4.3.0 or later.

Prototype

load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/contributed.ncl"

	procedure indStrSubset (
		str        [1] : string,  
		str_subset [1] : string   
	)

	return_val [*] :  integer

Arguments

str

Variable of type string which will be searched for a substring.

str_subset

Variable of type string specifying the subset.

Description

Return True if str_string is contained within the variable str; otherwise return False. The inputs, str and str_subset, are converted to characters. If str_subset is a subset, then the indices [subscripts] of the character sequence are returned. If str_subset is not a subset of str, then a integer missing value is returned.

See Also

isStrSubset

Examples

Example 1

If the string "orange" is a subset of "apple_orange_banana", return the indices of chararacter locations.

   aop = "apple_orange_banana"   
   o   = "orange"               
   ii  = indStrSubset(aop, o ) 
   if (.not.ismissing(ii)) then  
       print(ii)
   end if                                       
Variable: ii
Type: integer
Total Size: 24 bytes
            6 values
Number of Dimensions: 1
Dimensions and sizes:   [6]
Coordinates: 
(0)     6
(1)     7
(2)     8
(3)     9
(4)     10
(5)     11