{removeids:set1:set2}

Description

Set subtraction of two dash-separated id lists: returns set1 with every id that also appears in set2 removed, dash-separated. The remaining ids keep set1's original order. Built on array_diff over explode_ids, so each side is split on dashes, trimmed, and empty parts are dropped - leading, trailing or doubled dashes do not matter. An id listed in set2 is removed from set1 every time it occurs, but duplicate ids that are unique to set1 are kept (the command does not de-duplicate). It works on any dash-separated tokens, not only item ids. A common use is to take a few items out of a larger id list, for example all items a view returned except the current one. The companion command intersect keeps only the ids found in both lists.

Parameters

set1 optional default (empty)

The base list of ids, dash-separated. The result is built from this list - every id here is kept unless it also appears in set2. Split on dashes and trimmed; an empty set1 yields empty output.

set2 optional default (empty)

The list of ids to remove, dash-separated. Each id in this list is taken out of set1 wherever it occurs. Split on dashes and trimmed; an empty set2 leaves set1 unchanged. Ids in set2 that are not in set1 are simply ignored.

Examples

test[{removeids:{ids:9e1d2b9f88e3d6c3bf0eb967378610d6:d-headline........-==-Gamma}:5726c2c6b035d7aab450d1794e9e90d7}]
Expected[]
Actual[]
A real pattern: take a list of item ids from a query and remove a specific id. Here the only Gamma item is removed from the one-item Gamma result, leaving nothing. Swap the second argument for _#ITEM_ID_ to list all items of a view except the current one.
test{removeids:a-b-c-d:b-d}
Expecteda-c
Actuala-c
Remove the ids b and d from the list. What is left keeps set1's order.
test{removeids:3-1-4-1-5-9:9-1}
Expected3-4-5
Actual3-4-5
The result is ordered by set1, not by set2. Here 9 and 1 are removed wherever they appear.
test{removeids:a-b-c:x-y}
Expecteda-b-c
Actuala-b-c
When set2 shares no id with set1, set1 comes back unchanged.
test{removeids:a-b-c:}
Expecteda-b-c
Actuala-b-c
An empty second argument removes nothing, so the whole of set1 is returned.
test[{removeids::a-b}]
Expected[]
Actual[]
With nothing to subtract from, the result is empty. The square brackets are only there to make the empty output visible.
test[{removeids:a-b-c:a-b-c}]
Expected[]
Actual[]
When set2 contains every id of set1, the result is empty.
test{removeids:a - b - c: b }
Expecteda-c
Actuala-c
Each side is split on dashes and trimmed, and empty parts are dropped, so surrounding spaces and doubled dashes do not change the result.
test{removeids:5-5-3:3}
Expected5-5
Actual5-5
removeids does not de-duplicate. The id 5 appears twice and is not in set2, so both copies stay.
test{removeids:5-5-3:5}
Expected3
Actual3
When an id is in set2, every occurrence of it is taken out of set1, including duplicates.