I have such html which I use with twig. I tried to print 5 elements with comma
I want add "..." in the end of my tags.
Now it's look like apple, banana, orange, apple, apple, apple
And i want apple, banana, orange, apple, apple, apple, ...
Please, help me to solved this problem
You would need to add your ellipsis conditionally inside the loop.
e.g.
{% if i > 5 %} … {% endif %}
Related
I have two Lists in an excel spreadsheet.
The first list has strings such as
1234 blue 6 abc
xyz blue/white 1234
abc yellow 123
The other list contains substrings of the first list
yellow
blue/white
blue
Result
1234 blue 6 abc blue
xyz blue/white 1234 blue/white
abc yellow 123 yellow
Now I need some kind of match formula to assign the correct value from the second list to the first. The problem, there is no specific pattern to determine where the color substring is positioned. The other problem, the values are not totally unique. As my example above shows, the lookup needs to be in an order (checking for "blue/white" before checking for "blue").
I played around the formulas like match, find also using wildcards * but couldn't come to any result.
A similar question asked here on SO covers the opposite case How to find if substring exists in a list of strings (and return full value in list if so)
Any help is appriciated. A formula would be cool, but using vba is also okay.
=INDEX(D$7:D$9, AGGREGATE(15, 7, ROW($1:$3)/ISNUMBER(SEARCH(D$7:D$9, A2)), 1))
Here is a solution with VBA
List 1 (strings) is in column A
List 2 (substrings) is in column C
The code basically contains to nested while loops checking whether the substring is inside the string.
row_1 = 1
While .Cells(row_1, "A") <> ""
row_2 = 1
While .Cells(row_2, "C") <> ""
color = .Cells(row_2, "C").Value
If InStr(1, .Cells(row_1, "A"), color, vbBinaryCompare) > 0 Then
.Cells(row_1, "B") = color
End If
row_2 = row_2 + 1
Wend
row_1 = row_1 + 1
Wend
I am trying to use the following code
put 7 into lFoodID
lineoffset (lFoodID,gArrFood) into tArrFoodLine
to find the line that contain the number 7 in the array below
17 Banana
20 Beans
2 Beef
1 Bread
8 Cabagge
6 Chicken
5 Eggs
15 Ice Cream
3 Mango
7 Pork
18 Rice
4 Salad
19 fried fish
It's returning 1. I know that this is because 17 contains the number 7. I have tried
set the wholeMatches to true
but that does not work either. I believe that regex (^(7) should work but I can figure out how to use regex in lineoffset.
I'm not sure what you're really after and I wonder if your data really look like what you have provided here. I assume that your data are as displayed, but this may lead do a solution that's slightly different from what you really want.
If you want to get the product associated with an index, you can use the following script
put fld 1 into myList
replace space&space with tab in myList
repeat until (tab&tab is not in myList and space&space is not in myList)
replace space&space with space in myList
replace tab&tab with tab in myList
end repeat
split myList by cr and tab
put myList[7] into myProduct
put myProduct
MyProduct contains the product name. Note that you won't need the repeat loop if your data is formatted properly. If you really want to have the index, use this:
put fld 1 into myList
put 7 into myIndex
if word 1 of myList is not myIndex then
put number of lines of char 1 to offset(cr & "7" & space ,myList) of myList into myLine
else
put 1 into myLine
end if
put myLine
MyLine contains the complete record in your list.
I would like to know how to go about this. Imagine a text string such as this
/search/p300_action/search?catid=1&makeid=0&modelid=0&locid=1&yearmin=min&yearmax=max&pricemin=min&pricemax=max&conid=0&displaylocal=1&searchtext=Enter+Keyword(s)+/+AutoID
and I want to break down the info into respective categories such as makeid, modelid, yearmax etc... and relate the relevant categories into another page that have values for it. E.g lets say makeid: 0, 1, 2, 3 .... stands for makename: HP, samsung, compaq, acer respectively.
Kindly give me a simplified way to go about this.
I'm not at all clear what you require (and I'm not alone!) but maybe Text To Columns (Delimited and Other: & as delimiter) then something like =VLOOKUP(VALUE(RIGHT(B1,1)),Sheet2!A:B,2,FALSE)
I need to insert some missing line breakers in an one-column R dataframe. Those line breakers were missing from the data collection phase.
The data looks like:
V1
Apple
OrangeBanana
BananaBananaBanana
Watermelon
GrapeBanana
so all the line breakers before "Banana" are missing
I want to search for "Banana" and add those missing line breakers so it looks like:
V1
Apple
Orange
Banana
Banana
Banana
Banana
Watermelon
Grape
Banana
Here's a slightly more general solution, but one that can be easily purposed to explicitly working with "Banana".
V1 <- c("Apple", "OrangeBanana", "BananaBananaBanana", "Watermelon", "GrapeBanana")
First, let's split them up by finding all upper case letter which aren't word boundaries and replacing them with a space and an upper case letter:
splits <- gsub("(?:\\B)([[:upper:]])"," \\1" , V1, perl=TRUE)
[1] "Apple" "Orange Banana" "Banana Banana Banana" "Watermelon" "Grape Banana"
Then split by the space character and convert from list to vector:
unlist(strsplit(splits, " "))
[1] "Apple" "Orange" "Banana" "Banana" "Banana" "Banana" "Watermelon" "Grape" "Banana"
Or in one line:
unlist(strsplit(gsub("(?:\\B)([[:upper:]])"," \\1" , V1, perl=TRUE), " "))
EDIT: For a regex that works explicitly with "Banana":
gsub("(?:\\B)(Banana)"," \\1" , V1, perl=TRUE)
Hi I have a table with item codes in it eg.
A B C D E
Item 500ml 1000ml 2000ml 4000ml
1 Juice 8819686 8819687
2 Vinegar 8813998 8809981 8809982
3 Ice cream 8805690 8805691 8819815
Then I have another list of the above items (I've placed this next to the above table)
A B
Item Code
500ml Juice 8819686
1000ml Juice 8819687
500ml Vinegar 8813998
1000ml Vinegar 8809981
2000ml Vinegar 8809982
500ml Ice Cream 8805690
1000ml Ice Cream 8805691
2000ml Ice Cream 8819815
4000ml Ice Cream 8809984
I want to know which item code in the list is not appearing in the table above (ie. 8809984 is not in the table).
I tried using =IF(ISNA(MATCH(b2,$B$1:$E$E,0)),"Not Found", "Found"), but not working as it returns "Not Found" for every row.
Thank you
You can just use Countif for what you describe:
=CountIf(Sheet2!$B$1:$E$3,B2)>0
You'll get TRUE or FALSE as a result.
how about this way...
{=sum(if(b2=sheet2!$b$1:$e$3,1,0))}
this return 0 if there is no b2 in the target area, and 1 (or more if there are dups). it is array formula so you type everything except {} and then ctrl+alt+enter instead of regular enter.
once you confirmed that the table has unique entry of b2, then you will use following two formula to find index (assuming you do want to know).
{=sum(if(b2=sheet2!$b$1:$e$3,1,0)*{1,2,3,4})}
{=sum(if(b2=sheet2!$b$1:$e$3,1,0)*{1;2;3})}
top one tells the column, the bottom one tells row.
alternatively you could rearrange the original data somehow, but that's messy too...