def _compare_or_regex_search(a, b, regex=False):
if not regex:<EOL><INDENT>op = lambda x: operator.eq(x, b)<EOL><DEDENT>else:<EOL><INDENT>op = np.vectorize(lambda x: bool(re.search(b, x)) if isinstance(x, str)<EOL>else False)<EOL><DEDENT>is_a_array = isinstance(a, np.ndarray)<EOL>is_b_array = isinstance(b, np.ndarray)<EOL>if is_datetimelike_v_numeric(a, b):<EOL><INDENT>result = False<EOL><DEDENT>elif is_numeric_v_string_like(a, b):<EOL><INDENT>result = False<EOL><DEDENT>else:<EOL><INDENT>result = op(a)<EOL><DEDENT>if is_scalar(result) and (is_a_array or is_b_array):<EOL><INDENT>type_names = [type(a).__name__, type(b).__name__]<EOL>if is_a_array:<EOL><INDENT>type_names[<NUM_LIT:0>] = '<STR_LIT>'.format(dtype=a.dtype)<EOL><DEDENT>if is_b_array:<EOL><INDENT>type_names[<NUM_LIT:1>] = '<STR_LIT>'.format(dtype=b.dtype)<EOL><DEDENT>raise TypeError(<EOL>"<STR_LIT>".format(a=type_names[<NUM_LIT:0>],<EOL>b=type_names[<NUM_LIT:1>]))<EOL><DEDENT>return result<EOL>
Compare two array_like inputs of the same shape or two scalar values

Calls operator.eq or re.search, depending on regex argument. If regex is
True, perform an element-wise regex matching.

Parameters
----------
a : array_like or scalar
b : array_like or scalar
regex : bool, default False

Returns
-------
mask : array_like of bool