str_match_bool_ic
Returns a logical array of True/False/Missing indicating where the input array of strings contain the given substring (case insensitive).
Available in version 6.5.0 and later.
Prototype
function str_match_bool_ic ( string_array : string, sub_string [1] : string ) return_val [dimsizes(string_array)] : logical
Arguments
string_arrayA string array of any dimensionality.
sub_stringThe substring to be matched.
Description
This function returns a logical array the same size as the input string_array that is set to True for every element that contains sub_string, the logical "Missing" for every value that is missing in the string_array, and False otherwise.
str_match_bool_ic is case INSENSITIVE. Use str_match_bool if you need case sensitivity.
Jared Lee (NCAR/RAL) contributed the original version of str_match_bool, which this function is adapted from.
See Also
str_match_bool, str_index_of_substr, str_sub_str, str_match, str_match_ic, str_match_ind, str_match_ind_ic, str_match_regex, str_match_ic_regex, str_match_ind_regex, str_match_ind_ic_regex
Examples
Example 1
s = (/ "foo", "bar", "missing", "Foo", "FOOBAR", "barfoo", "oof" /) s@_FillValue = "missing" smb = str_match_bool_ic(s, "foo") print(smb)Output:
Variable: smb_ic
Type: logical
Total Size: 28 bytes
7 values
Number of Dimensions: 1
Dimensions and sizes:[7]
Coordinates:
Number Of Attributes: 1
_FillValue :Missing
True
False
Missing
True
True
True
False
Example 2If you need the return array to be False at locations where the input strings are missing (instead of the logical "Missing"), then use the following:
smb = str_match_bool_ic(s, "foo") smb = where(ismissing(smb), False, smb) print(smb)Output:
Variable: smb_ic
Type: logical
Total Size: 28 bytes
7 values
Number of Dimensions: 1
Dimensions and sizes:[7]
Coordinates:
Number Of Attributes: 1
_FillValue :Missing
True
False
False
True
True
True
False