Creates a new list containing only those elements that match the given string.

Syntax

List = SRP_List_Reduce(Handle, StringToMatch, MatchAnywhereFlag)

Returns

Handle to a new list containing only those elements that match the given string.

Parameters

ParameterDescription
HandleHandle to an existing SRP List (REQUIRED)
StringToMatchThe string to find in the SRP List (REQUIRED)
MatchAnywhereFlagIf true, a match occurs if the string appears anywhere in the element. Otherwise, the whole element must match (REQUIRED)

Remarks

The SRP_List_Reduce method searches for the all elements that match the given target and returns a new list with just those matches. The search is not case sensitive. A match occurs if the whole element has the same text unless the MatchAnywhereFlag is set to 1, in which case the string can appear anywhere in an element. For example, if MatchAnywhereFlag is 1 and you are searching for "AND", there will be a successful match against "Branded".

IMPORTANT: You should always release the handle to an SRP List when you no longer need it by calling SRP_List_Release.

Examples

// Create the list
Handle = SRP_List_Create("Apple Pie,Banana Cream Pie,Chocolate Cake,Pie", ",")

// This will return "Pie", since the search is looking for elements that entirely match "pie"
ReducedHandle1 = SRP_List_Reduce(Handle, "pie", 0)

// This will return "Apple Pie,Banana Cream Pie,Pie", since the search is looking for any element containing "pie" anywhere
ReducedHandle2 = SRP_List_Reduce(Handle, "pie", 1)
 
// Play nice with memory
SRP_List_Release(Handle)
SRP_List_Release(ReducedHandle1)
SRP_List_Release(ReducedHandle2)
  • No labels