Finds the index of the first element from the starting index that matches the given string.
Index = SRP_List("Match", Handle, StringToMatch, StartIndex, Option)
The index of the first element that matches the target value.
|Handle||Handle to an existing SRP List (REQUIRED)|
|StringToMatch||The string to find in the SRP List (REQUIRED)|
|StartIndex||The index to start the search (OPTIONAL)|
|Option||If "MatchAnywhere", a match occurs if the string appears anywhere in the element. If "MatchAll", the whole element must match (OPTIONAL)|
The Match service searches for the first element that matches the given target and returns its index. The search is not case sensitive, unlike the Locate service. A match occurs if the whole element has the same text unless the Option is set to "MatchAnywhere", in which case the string can appear anywhere in an element. For example, if Option is "MatchAnywhere" and you are searching for "AND", there will be a successful match against "Branded". "MatchAnywhere" is the default when the parameter is omitted.
The SearchIndex parameter tells the Match routine where to start the search. Set it to 1 or 0 to start at the beginning of the list. If, for example, you set the StartIndex to 5, then the search will begin at the fifth element and proceed down the list. If omitted, the search will start at the beginning of the list.
The Match service is slower than the Locate service, because the Locate service uses case sensitive indexing for immediate results. If you need to find case sensitive exact matches, then Locate will be much faster.
// Create the list Handle = SRP_List("Create", "Apple Pie,Banana Cream Pie,Chocolate Cake,Pie", ",") // This will return 4, since the search is looking for an element whose entire element matches "pie" Index = SRP_List("Match", Handle, "pie", 1, "MatchAll") // This will return 1, since the search is looking for an element containing "pie" anywhere Index = SRP_List("Match", Handle, "pie") // This will return 2, since the search starts at index 2 Index = SRP_List("Match", Handle, "pie", 2, "MatchAnywhere") // Play nice with memory SRP_List("Release", Handle)