I have a database column, delimited by colons, describing a category hierarchy like so:
ID | Category
100 | Domestic:Trees:Fruit:Apples
I would like to extract only the third segment of the hierarchy “Fruit” from the text. How can I use Linq Regex or Linq Filtering to extract just that segment? Is it a good idea to extract information this way for every time a user selects a category?
Your question makes it sound like you want a linq answer only – so if you wanted to use linq, you could do this…
Doing it in linq vs just splitting the string and taking the one you need isn’t going to make your code any easier to read – so you may want to just consider going with just a straight split as Andrew suggested.