Return matches from array if contains specific words

excel check if cell contains text from list and return value
if cell contains text from list then return value
excel if range of cells contains specific text
if cell contains specific text then return value
excel check if cell contains text from list and return text
check if a string is in an array of strings java
if cell contains (multiple text criteria) then return (corresponding text criteria)
index match

I have an array that contains several countries followed by an option and a number.

0 " UK One 150 "

1 " Switzerland Two 70 "

2 " China Two 120 "

3 " Switzerland One 45 "

4 " China One 90 "

5 " UK Two 50 "

This is how I get the array using xpath:

    var iterator = document.evaluate('//xpath/li[*]', document, null, XPathResult.UNORDERED_NODE_ITERATOR_TYPE, null);

try {
  var thisNode = iterator.iterateNext();
  var arrayList = [];

  while (thisNode) {
    thisNode = iterator.iterateNext();

  for (var i = 0; i < arrayList.length; i++) {
} catch (e) {
  dump('Error' + e);

What I would like to do with this array is to sort out and return only the matches. E.g. I would like for it to return only UK and China, so the array would look like this.

0 " UK One 150 "

1 " China Two 120 "

2 " China One 90 "

3 " UK Two 50 "

You can do it like this with help of sort() filter() and regex

What i did is first filter all the elements which contains either UK or China.

Now on this filtered array i need to capture the number using regex and sorted them in descending order.

let arr =[
"UK One 150 ",
"Switzerland Two 70 ",
"China Two 120 ",
"Switzerland One 45 ",
"China One 90 ",
"UK Two 50 ",

let op = arr.filter(e=> 
   .sort((a,b)=>{a.match(/\d+/g) - b.match(/\d+/g)}

Return matches from array if contains specific words, Return matches from array if contains specific words. excel check if cell contains text from list and return value if cell contains text from list then return value To use XLOOKUP to match values that contain specific text, you can use wildcards and concatenation. In the example shown, the formula in F5 is: = XLOOKUP("*" & E5 & "*", code, quantity,"no match",2) where code (B5:B15) and quantity (C5:C15) are named ranges.

You can filter your array using the regular expression and then sort the result on the numeric value.

let data =["UK One 150 ","Switzerland Two 70 ","China Two 120 ","Switzerland One 45 ","China One 90 ","UK Two 50 "],
  result = ((arr) => data.filter(s => new RegExp(arr.join('|'), 'ig').test(s)))(['UK', 'China'])
          .sort((a,b)=> +a - +b);

If cell contains text from list, Specific wkdays in rng The remaining examples show formulas that also return the matching values. The image above shows an array formula in cell C3 that checks if cell B3 Step 1 - Count cells containing text strings. HOW TO: "If cell contains specific text then return specific text" I'm trying to extract a bunch of specific text combinations from cells and present it in a new cell. This formula seems to work for two variables but I can't add any more variables too it.

You can use a form of Schwartzian transform to "decorate" the data by extracting the name of the country, and the number using a and regex.

Now you can filter by the country, sort by the number, and extract the str using another map.

const arr =[
"UK One 150 ",
"Switzerland Two 70 ",
"China Two 120 ",
"Switzerland One 45 ",
"China One 90 ",
"UK Two 50 ",

const pattern = /^(\S+)\D+(\d+)/;
const requestedCounteries = new Set(['UK', 'China']);

const result = arr
  .map(str => str.match(pattern)) // ['UK One 150 ', 'UK', '150']
  .filter(([,country]) => requestedCounteries.has(country))
  .sort(([,,a], [,,b]) => +b - +a)
  .map(([str]) => str);

Excel formula: Get first match cell contains, If the cell contains the substring, the expression returns TRUE. If not, the This array is returned to the MATCH function as the array argument. The look up value​  This array contains as many values as there values in the list, the position of each value in the array matches the position of the value in the list. This means that we can tell from the array that the first value and the last value is found in cell B3.

Excel formula: If cell contains one of many things, If the cell contains the substring, the formula returns TRUE. To simplify the array, we use the ISNUMBER function to convert all items in the array to either TRUE or FALSE. ISNUMBER + SEARCH approach is you may get false matches from partial matches inside longer words. Excel formula: Cell contains specific text. This post will guide you how to return a value if a cell contains a certain number or text string in Excel. How do I check if a Cell contains specific text and then return another specific text in another cell with a formula in Excel. Return Value If Cell Contains Certain Value Video: Return read more »

JavaScript Includes To Search In Strings & Arrays, Learn how to search arrays and strings to determine if they contain your item. How to Use JavaScript ‍ includes to Find Matches in Strings and Arrays The method returns true or false to indicate if the sub-string or  If A Range Contains Specific Text, Return Adjacent Cell Value If a column of text has a specific value "New Deal" how to I get it to return the cell next to it that contains the dollar amount? I am wanting Excel to quickly sort and enter the data from the left three columns into the middle section to separate everything out.

match() \ Language (API) \ Processing 3+, If there are no matches, a null value will be returned. If no groups are specified in the regular expression, but the sequence matches, an array of  In the case of multiple matches found, the formula will return the last match from the list of " Cell contains one of many things To test a cell to see if it contains one of many strings, you can use a formula based on the SEARCH , ISNUMBER and SUMPRODUCT functions.

  • You can use the filter method.
  • Please share the array.