NCL Home >
Documentation >
Functions >
String manipulation
isStrSubset
Return True or False if one string is a subset of another string.
Available in version 4.3.0 or later.
Prototype
load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/contributed.ncl" function isStrSubset ( str [1] : string, str_subset [1] : string ) return_val [1] : logical
Arguments
strVariable of type string which will be searched for a substring.
str_subsetVariable of type string specifying the subset.
Description
Return True if str_string is contained within the variable str; otherwise return False.
See Also
Examples
Example 1
Is the string "orange" a subset of "apple_orange_banana"?
aop = "apple_orange_banana"
o = "orange"
tf = isStrSubset(aop, o )
if (tf) then
print(o+" is a subset of input string: "+aop)
else
print(o+" is NOT a subset of input string: "+aop)
end if
Here, tf=True and the oupt is
orange is a subset of input string: apple_orange_banana
Example 2
Given an ascii file ["Station.Data"] containing station names and data, search each line for a station named "San Francisco".
S = asciiread ("Station.Data", -1, "string")
do n=0,nlines-1
tf = isStrSubset( S(n), "San Francisco")
if (tf) then
.... do something ....
break ; jump to statement after the 'end do'
end
end do