-2

I have a List, named values which contains values similar to the following string values:
GKgpuzjBUh IS1bbf2ffd806f6d IS102a8a395ced93 Dark Von Diakonov IS148159f7c24f78

I need to check if the specific a string in the starts with IS1

Robert MacLean
  • 38,975
  • 25
  • 98
  • 152
Cata
  • 101
  • 1
  • 12

2 Answers2

1

You dont need regex. Use str.StartsWith("IS1").

Dmytro Marchuk
  • 478
  • 5
  • 10
1

Not clear from the question, so here are a few options.

You want to find out if ANY string in the list starts with IS1

var found = values.Any(item => item.StartsWith("IS1"));

You want to find all the strings in the list which start with IS1

var matches = values.Where(item => item.StartsWith("IS1"));

Robert MacLean
  • 38,975
  • 25
  • 98
  • 152