What is the best/cleanest way you know of to take a comma delimited string, such as "A,B,C,D,E,F,G", and return only the 1st 5 amount of items in the list? So the result would be "A,B,C,D,E".
I don't want to split first and perform this operation to increase record volume. Please let me know if there is any another way to perform this operation.
Solved! Go to Solution.
I would probably just split the string and combine it unless you are dealing with extremely large data sets. My next choice would be using REGEX, which would probably be faster, but harder for many to understand. I'm no REGEX expert and I'm sure someone can come up with a more elegant example but the attached does what you want.
The pattern is just five instances of characters that don't include "," separated by commas: "([^,]*,[^,]*,[^,]*,[^,]*,[^,]*).*" -> "$1"
User | Count |
---|---|
19 | |
14 | |
13 | |
9 | |
8 |