I’m going to put on my “professional programmer” hat here. Even if this solution happens to work for you now, I would advise against using it. Perhaps sometime in the future, in a year or two, you’ll start adding ID’s with additional digits. By then, you’ll have forgotten all about the fact that this code doesn’t work correctly in that situation. It might produce incorrect results for weeks, months or even years without you ever noticing it, then when you do notice it, you’ll have to track it down and figure out the problem from scratch, since you’ll undoubtably have forgotten all about today’s discussion.
This is why I also recommend that Vic revise his code now, while this is all fresh. It may or may not be working ok for him now, but it could be a difficult to track down problem in the future.
Vic, I want to commend you again for piping up. Please don’t be discouraged by the fact that there was a bit of a problem with your solution. Hopefully this discussion has been educational for others, and perhaps the fact that you spoke up will save you from some problems down the road. I think this task (selecting based on contents of an array) is probably pretty common, so it’s good to have a full discussion of the pros and cons of various techniques.
By the way, there is a way that you can use the search function to do this reliably, by adding some extra separator characters to the formula like this:
This will work 100% reliably just like the arraycontains( solution, even if the array elements have different lengths.