Datetime exact match check as well as between check
@param string $content
@param string $search
@param string $type
@return bool
779452
public function filter($content, $search, $type)
    {
        $search = is_array($search) ? $search : [$search];
        $search = array_map(function($searchValue) {return is_a($searchValue, Carbon::class) ? $searchValue : new Carbon($searchValue);}, $search);
        $current = (new Carbon($content));
        switch ($type) {
            case 'in':
                return ($current->gte($search[0]) && $current->lt($search[1]));
                break;
            default:
                return $current->eq($search[0]);
        }
    }
230848
public boolean matchContentType(String contentTypeRegex) {
        if (contentTypeRegex == null) {
            return contentType() == null;
        }
        return Pattern.matches(contentTypeRegex, contentType());
    }
8183
public boolean matchType(CmsLogEntryType type) {

        if (m_excludeTypes.contains(type)) {
            return false;
        }
        if (m_includeTypes.isEmpty()) {
            return true;
        }
        return m_includeTypes.contains(type);
    }
1060821
protected function validate_date_part($type, $value)
    {
        // we do simple validation of date/part format
        switch ($type) {
            case 'date': // yyyy-mm-dd
                return preg_match('/^[0-9]{4}-[0-9]{2}-[0-9]{2}$/', $value);
            case 'iso8601':
                return preg_match('/^[0-9: .,ZWT+-]+$/', $value);
            case 'std11':
                return preg_match('/^((Sun|Mon|Tue|Wed|Thu|Fri|Sat),\s+)?[0-9]{1,2}\s+'
                    . '(Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec)\s+[0-9]{2,4}\s+'
                    . '[0-9]{2}:[0-9]{2}(:[0-9]{2})?\s+([+-]*[0-9]{4}|[A-Z]{1,3})$', $value);
            case 'julian':
                return preg_match('/^[0-9]+$/', $value);
            case 'time': // hh:mm:ss
                return preg_match('/^[0-9]{2}:[0-9]{2}:[0-9]{2}$/', $value);
            case 'year':
                return preg_match('/^[0-9]{4}$/', $value);
            case 'month':
                return preg_match('/^[0-9]{2}$/', $value) && $value > 0 && $value < 13;
            case 'day':
                return preg_match('/^[0-9]{2}$/', $value) && $value > 0 && $value < 32;
            case 'hour':
                return preg_match('/^[0-9]{2}$/', $value) && $value < 24;
            case 'minute':
                return preg_match('/^[0-9]{2}$/', $value) && $value < 60;
            case 'second':
                // According to RFC5260, seconds can be from 00 to 60
                return preg_match('/^[0-9]{2}$/', $value) && $value < 61;
            case 'weekday':
                return preg_match('/^[0-9]$/', $value) && $value < 7;
            case 'zone':
                return preg_match('/^[+-][0-9]{4}$/', $value);
        }
    }
488130
public static function ensureRight($string, $search, $encoding = null)
    {
        if (static::endsWith($string, $search, true, $encoding)) {
            return $string;
        }

        return $string . $search;
    }
489141
function contains(origin, search, start) {
  'use strict';
  if (typeof start !== 'number') {
    start = 0;
  }
  if (start + search.length > origin.length) {
    return false;
  } else {
    return origin.indexOf(search, start) !== -1;
  }
}
775097
function checkSearchTerm(searchTerm){
		if (!is_string(searchTerm) && !is_numeric(searchTerm)){
			console.log('\nError: This must be either a string or an interval:\n', searchTerm, ' \n');
			return false;
		} else {
			return true;
		}
	}
855753
public function match($type, $value = null)
    {
        if ($this->type === $type || (is_array($type) && in_array($this->type, $type))) {
            if (null === $value || $this->value == $value || (is_array($value) && in_array($this->value, $value))) {
                return true;
            }
        }
        return false;
    }
838742
def match_content_types_for(content_types, type)
      content_types.detect do |content_type, _|
        content_type.is_a?(Regexp) ? type.match(content_type) : type == content_type
      end
    end
230423
public function check($value,$rule,$type='regex'){
        $type   =   strtolower(trim($type));
        switch($type) {
            case 'in': // 验证是否在某个指定范围之内 逗号分隔字符串或者数组
            case 'notin':
                $range   = is_array($rule)? $rule : explode(',',$rule);
                return $type == 'in' ? in_array($value ,$range) : !in_array($value ,$range);
            case 'between': // 验证是否在某个范围
            case 'notbetween': // 验证是否不在某个范围            
                if (is_array($rule)){
                    $min    =    $rule[0];
                    $max    =    $rule[1];
                }else{
                    list($min,$max)   =  explode(',',$rule);
                }
                return $type == 'between' ? $value>=$min && $value<=$max : $value<$min || $value>$max;
            case 'equal': // 验证是否等于某个值
            case 'notequal': // 验证是否等于某个值            
                return $type == 'equal' ? $value == $rule : $value != $rule;
            case 'length': // 验证长度
                $length  =  mb_strlen($value,'utf-8'); // 当前数据长度
                if(strpos($rule,',')) { // 长度区间
                    list($min,$max)   =  explode(',',$rule);
                    return $length >= $min && $length <= $max;
                }else{// 指定长度
                    return $length == $rule;
                }
            case 'expire':
                list($start,$end)   =  explode(',',$rule);
                if(!is_numeric($start)) $start   =  strtotime($start);
                if(!is_numeric($end)) $end   =  strtotime($end);
                return NOW_TIME >= $start && NOW_TIME <= $end;
            case 'ip_allow': // IP 操作许可验证
                return in_array(get_client_ip(),explode(',',$rule));
            case 'ip_deny': // IP 操作禁止验证
                return !in_array(get_client_ip(),explode(',',$rule));
            case 'regex':
            default:    // 默认使用正则验证 可以使用验证类中定义的验证名称
                // 检查附加规则
                return $this->regex($value,$rule);
        }
    }
234588
protected function isRelevant(string $content): bool
    {
        $whitelist = [
            'Facade',
            'Service',
            'QueryContainer',
            'Client',
        ];

        foreach ($whitelist as $classType) {
            $length = strlen($classType);
            if (substr($content, -$length) === $classType) {
                return true;
            }
        }

        return false;
    }
836211
protected function matchParentType(
        /*# string */ $childType,
        array $typesToCheck,
        array &$result
    )/*# : bool */ {
        foreach ($typesToCheck as $type) {
            if ($this->isAType($childType) &&
                is_a($childType, $type, true)
            ) {
                $result[$type] = true;
            }
        }
    }
160903
public function find( $search ) {

		if ( ! is_array( $search ) ) {
			$search = (array) $search;
		}

		foreach ( $search as $val ) {
			if ( $this->fulltextSearchInPost( $val ) !== false ) {
				return true;
			}
			if ( $this->fulltextSearchInMeta( $val ) !== false ) {
				return true;
			}
		}

		return false;
	}
150269
private boolean matchesDay(DateTime currentTime, TimeRestrictedAccess filter) {
        Integer dayStart = filter.getDayStart();
        Integer dayEnd = filter.getDayEnd();
        int dayNow = currentTime.getDayOfWeek();
        if (dayStart >= dayEnd) {
            return dayNow >= dayStart && dayNow <= dayEnd;
        } else {
            return dayNow <= dayEnd && dayNow >= dayStart;
        }
    }
424657
private function match(int $type)
    {
        if (! $this->lexer->isNextToken($type)) {
            $this->syntaxError();
        }

        $value = $this->lexer->lookahead['value'];
        $this->lexer->moveNext();

        return $value;
    }
1337470
protected function compare_search_value($colname, $value, $search, $mode)
    {
        // The value is a date string, for date we'll
        // use only strict comparison (mode = 1)
        // @TODO: partial search, e.g. match only day and month
        if (in_array($colname, $this->date_cols)) {
            return (($value = rcube_utils::anytodatetime($value))
                && ($search = rcube_utils::anytodatetime($search))
                && $value->format('Ymd') == $search->format('Ymd'));
        }

        // Gender is a special value, must use strict comparison (#5757)
        if ($colname == 'gender') {
            $mode = self::SEARCH_STRICT;
        }

        // composite field, e.g. address
        foreach ((array)$value as $val) {
            $val = mb_strtolower($val);

            if ($mode & self::SEARCH_STRICT) {
                $got = ($val == $search);
            }
            else if ($mode & self::SEARCH_PREFIX) {
                $got = ($search == substr($val, 0, strlen($search)));
            }
            else {
                $got = (strpos($val, $search) !== false);
            }

            if ($got) {
                return true;
            }
        }

        return false;
    }
730671
public function getContentTypeFieldType($contenttypeslug, $fieldname)
    {
        $contenttype = $this->getContentType($contenttypeslug);

        if (in_array($fieldname, ['datecreated', 'datechanged', 'datepublish', 'datedepublish'])) {
            return "datetime";
        } elseif (isset($contenttype['fields'][$fieldname]['type'])) {
            return $contenttype['fields'][$fieldname]['type'];
        } else {
            return false;
        }
    }