
str_match_ic
Returns a list of strings that contain the given substring (case insensitive).
Available in version 6.0.0 and later.
Prototype
function str_match_ic ( string_array : string, sub_string [1] : string ) return_val [*] : string
Arguments
string_arrayA string array of any dimensionality.
sub_stringThe substring to be matched.
Return value
Note that the return value will always be a one-dimensional array, regardless of the dimensionality of the input array. See the examples below.
Description
This function returns an array of strings with every occurrence of sub_string matched in string_array.
If there is no sub_string matched in string_array, the default string missing value ("missing") will be returned.
Note that str_match_ic is case INSENSITIVE. Use str_match if you need case sensitivity.
See Also
str_index_of_substr, str_sub_str, str_match, str_match_regex, str_match_ic_regex, str_match_ind_regex, str_match_ind_ic_regex, str_match_ind, str_match_ind_ic
Examples
Example 1
s = (/"Linux","LINUX","linux"/) dq = str_get_dq() print("str_match(s," + dq + "linux" + dq + ") = " + str_match(s,"linux")) ;print out: ;(0) str_match(s,"linux") = linux print("str_match_ic(s," + dq + "linux" + dq + ") = " + str_match_ic(s,"linux")) ;print out: ;(0) str_match_ic(s,"linux") = Linux ;(1) str_match_ic(s,"linux") = LINUX ;(2) str_match_ic(s,"linux") = linuxExample 2
Create a 3 x 10 string array with dummy year and month values. str_match always returns a 1D array regardless of the input array dimensionality:
;---Create dummy input array months = (/"Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"/) array2d = new((/3,10/),string) array2d(0,:) = months(0:9) + " 1999" array2d(1,:) = months(2:11) + " 2000" array2d(2,:) = "Jan 20" + sprinti("%02i",ispan(1,10,1)) ;---Print dummy input array slist = [/array2d(0,:),array2d(1,:),array2d(2,:)/] print_table([/"================================"/],"%s") print_table([/" array2d"/],"%s") print_table([/"================================"/],"%s") print_table(slist," %s %s %s") print_table([/"================================"/],"%s") ;---Match all strings that contain the letters "O" or "U" O_strs = str_match_ic(array2d,"O") u_strs = str_match_ic(array2d,"u") ;---Print results of various string matching statements print("O_strs = " + str_join(O_strs,",")) print("u_strs = " + str_join(u_strs,","))
Output:
================================ array2d ================================ Jan 1999 Mar 2000 Jan 2001 Feb 1999 Apr 2000 Jan 2002 Mar 1999 May 2000 Jan 2003 Apr 1999 Jun 2000 Jan 2004 May 1999 Jul 2000 Jan 2005 Jun 1999 Aug 2000 Jan 2006 Jul 1999 Sep 2000 Jan 2007 Aug 1999 Oct 2000 Jan 2008 Sep 1999 Nov 2000 Jan 2009 Oct 1999 Dec 2000 Jan 2010 ================================ O_strs = Oct 1999,Oct 2000,Nov 2000 u_strs = Jun 1999,Jul 1999,Aug 1999,Jun 2000,Jul 2000,Aug 2000