Ganesha
Ganesha

Reputation: 1531

LINQ Select Question

I have a List<SomeType> where

SomeType.Value = "TASK?" where '?' can be from 1 to N.

SomeType.Value can also have values like TASKCNT, TASKOLD etc..

The question is how do I Select all "TASK?" ignoring other values like TASKCNT, TASKOLD

Thanks in advance

Upvotes: 1

Views: 188

Answers (1)

Jacob
Jacob

Reputation: 78860

If this is a simple LINQ to objects, you can just use a regular expression:

var regex = new Regex(@"^TASK\d$");
var tasks = 
    from task in theTasks
    where regex.IsMatch(task.Value);
    select task;

Upvotes: 4

Related Questions