maxkueng/viewportsizes · index.js
javascript logo
function list (search) {
	if (!search) {
		return sizes;
	}

	var regex = new RegExp(search, 'i');

	return sizes.filter(function (item) {
		return regex.test(item.fulltext)
	});
}
Similar code snippets
1.
anandthakker/doiuse · detect-feature-use.js
Match rating: 54.67% · See similar code snippets
javascript logo
function find (searchfor) {
    if (searchfor instanceof RegExp) return searchfor.test(str)
    else if (typeof searchfor === 'function') return searchfor(str)
    else return str && str.indexOf(searchfor) >= 0
  }
2.
eclipse/orion.client · searchUtils.js
Match rating: 54.5% · See similar code snippets
javascript logo
function(searchParams) {
	if(searchParams.rows !== undefined){
		searchParams.rows = parseInt(searchParams.rows, 10);
	}
	if(searchParams.start !== undefined){
		searchParams.start = parseInt(searchParams.start, 10);
	}
	if(typeof searchParams.regEx === "string"){ //$NON-NLS-0$
		searchParams.regEx = (searchParams.regEx.toLowerCase() === "true"); //$NON-NLS-0$
	}
	if(typeof searchParams.caseSensitive === "string"){ //$NON-NLS-0$
		searchParams.caseSensitive = (searchParams.caseSensitive.toLowerCase() === "true"); //$NON-NLS-0$
	}
	if(typeof searchParams.nameSearch === "string"){ //$NON-NLS-0$
		searchParams.nameSearch = (searchParams.nameSearch.toLowerCase() === "true"); //$NON-NLS-0$
	}
	if(searchParams.fileNamePatterns !== undefined){
		searchParams.fileNamePatterns = searchUtils.getFileNamePatternsArray(searchParams.fileNamePatterns);
	}
}
3.
Neft-io/neftio · search.js
Match rating: 54.16% · See similar code snippets
javascript logo
function () {
            var value = inputElement.value;
            var searchResult = search(value);
            if (value && !searchResult.length && lastSearchResult) {
                searchResult = lastSearchResult;
            }
            showResult(value, searchResult)
            lastSearchResult = searchResult;
        }
4.
zloirock/core-js · esnext.string.replace-all.js
Match rating: 53.27% · See similar code snippets
javascript logo
function replaceAll(searchValue, replaceValue) {
    var O = requireObjectCoercible(this);
    var search, flags;
    if (isRegExp(searchValue)) {
      flags = getRegExpFlags.call(searchValue);
      if (!~flags.indexOf('g')) {
        search = new (speciesConstructor(searchValue, RegExp))(searchValue.source, flags + 'g');
      } else search = searchValue;
      return String(O).replace(search, replaceValue);
    }
    return String(O).split(searchValue).join(replaceValue);
  }
5.
mobxjs/mobx-devtools · nodeMatchesText.js
Match rating: 53.06% · See similar code snippets
javascript logo
function validString(str, needle, regex) {
  if (regex) {
    try {
      const regExp = SearchUtils.searchTextToRegExp(needle);
      return regExp.test(str.toLowerCase());
    } catch (error) {
      return false;
    }
  }
  return str.toLowerCase().indexOf(needle) !== -1;
}
6.
javascript logo
function(searchText) {
  function parseSearchFilters() {
    /* Filter search by type, eg 'is:wms fish' or '-is:wfs house'. Multiple 'is' clauses are or-ed. */
    var isRE = /(^|\s)(-?)is:([a-zA-Z0-9_-]+)\b/i;
    while (searchText.match(isRE)) {
      if (!searchText.match(isRE)[2]) {
        searchFilters.typeIs.push(searchText.match(isRE)[3].toLowerCase());
      } else {
        searchFilters.typeIsNot.push(searchText.match(isRE)[3].toLowerCase());
      }
      searchText = searchText.replace(isRE, "").trim();
    }
    /* Change number of search results: 'show:20' or 'show:all' */
    var showRE = /\bshow:(all|[0-9]+)\b/i;
    while (searchText.match(showRE)) {
      searchFilters.maxResults = searchText.match(showRE)[1].toLowerCase();
      if (searchFilters.maxResults === "all") {
        searchFilters.maxResults = 10000;
      } else {
        searchFilters.maxResults = parseInt(searchFilters.maxResults, 10);
      }
      searchText = searchText.replace(showRE, "").trim();
    }

    /* Filter by URL: 'url:landgate.wa' or '-url:geoserver.nicta.com.au' */
    var urlRE = /(^|\s)(-?)url:([^ ]+)(\b|$)/i;
    while (searchText.match(urlRE)) {
      if (!searchText.match(urlRE)[2]) {
        searchFilters.urlMatches.push(searchText.match(urlRE)[3].toLowerCase());
      } else {
        searchFilters.urlDoesNotMatch.push(
          searchText.match(urlRE)[3].toLowerCase()
        );
      }
      searchText = searchText.replace(urlRE, "").trim();
    }
  }

  if (this._searchInProgress) {
    this._searchInProgress.cancel = true;
    this._searchInProgress = undefined;
  }

  if (!defined(searchText) || /^\s*$/.test(searchText)) {
    this.isSearching = false;
    this.searchResults.removeAll();
    return;
  }

  var searchFilters = {
    typeIs: [],
    typeIsNot: [],
    urlMatches: [],
    urlDoesNotMatch: []
  };
  parseSearchFilters();

  this.isSearching = true;
  this.searchResults.removeAll();
  this.searchMessage = undefined;

  this.terria.analytics.logEvent("search", "catalogue", searchText);

  var searchInProgress = (this._searchInProgress = {
    cancel: false
  });

  var path = [];
  var topLevelGroup = this.terria.catalog.group;
  var promise = findMatchingItemsRecursively(
    this,
    searchInProgress,
    new RegExp(searchText, "i"),
    topLevelGroup,
    path,
    undefined,
    searchFilters
  );

  var that = this;
  return when(promise).then(function() {
    that.isSearching = false;

    if (searchInProgress.cancel) {
      return;
    }

    if (that.searchResults.length === 0) {
      that.searchMessage = "Sorry, no catalogue items match your search query.";
    }
  });
}
7.
DavidSouther/JEFRi · angular-ui.js
Match rating: 52.4% · See similar code snippets
javascript logo
function () {
  return function (text, search, caseSensitive) {
    if (search || angular.isNumber(search)) {
      text = text.toString();
      search = search.toString();
      if (caseSensitive) {
        return text.split(search).join('<span class="ui-match">' + search + '</span>');
      } else {
        return text.replace(new RegExp(search, 'gi'), '<span class="ui-match">$&</span>');
      }
    } else {
      return text;
    }
  };
}
8.
eclipse/orion.client · searchUtils.js
Match rating: 51.98% · See similar code snippets
javascript logo
function(searchParams, fromStart) {
	var searchStr = searchParams.keyword;
	var displayedSearchTerm = searchStr;
	var inFileQuery = {};
	if(searchParams.fileType && searchParams.fileType !== searchUtils.ALL_FILE_TYPE && searchStr === ""){
		displayedSearchTerm = "*." + searchParams.fileType; //$NON-NLS-0$
	}
	if(!searchParams.regEx){
		var hasStar = (searchStr.indexOf("*") > -1); //$NON-NLS-0$
		var hasQMark = (searchStr.indexOf("?") > -1); //$NON-NLS-0$
		if(hasStar){
			searchStr = searchStr.split("*").join(".*"); //$NON-NLS-1$ //$NON-NLS-0$
		}
		if(hasQMark){
			searchStr = searchStr.split("?").join("."); //$NON-NLS-1$ //$NON-NLS-0$
		}
		if(searchParams.wholeWord){
			//escape all meta characters in string literal search except for * and .(when * or ? present)
			searchStr = hasStar || hasQMark ? searchStr.replace(/[-[\]{}()+,\\^$|#\s]/g, "\\$&") : searchStr.replace(/[-[\]{}()+.,\\^$|#\s]/g, "\\$&") ;
		}
		if(!hasStar && !hasQMark && !searchParams.nameSearch && !searchParams.wholeWord){
			inFileQuery.searchStr = searchParams.caseSensitive ? searchStr.split("\\").join("") : searchStr.split("\\").join("").toLowerCase(); //$NON-NLS-3$ //$NON-NLS-2$ //$NON-NLS-1$ //$NON-NLS-0$
			inFileQuery.wildCard = false;
		} else {
			inFileQuery.searchStr = searchParams.caseSensitive ? searchStr : searchStr.toLowerCase();
			_generateSearchHelperRegEx(inFileQuery, searchParams, fromStart);
			inFileQuery.wildCard = true;
		}
	} else {
		inFileQuery.searchStr =searchStr;
		_generateSearchHelperRegEx(inFileQuery, searchParams, fromStart);
	}
	inFileQuery.searchStrLength = inFileQuery.searchStr.length;
	return {params: searchParams, inFileQuery: inFileQuery, displayedSearchTerm: displayedSearchTerm};
}
9.
LvChengbin/url · url.cjs.js
Match rating: 51.88% · See similar code snippets
javascript logo
function encodeSearch( search ) {
    if( !search ) return search;
    return '?' + search.substr( 1 ).replace( /[^&=]/g, m => encodeURIComponent( m ) );
}
10.
mde/utilities · string.js
Match rating: 51.47% · See similar code snippets
javascript logo
function (searchIn, searchFor) {
    var str = searchFor;
    if (!str && typeof string != 'string') {
      return false;
    }
    str = String(str);
    return (searchIn.indexOf(str) > -1);
  }