Reputation: 339
I have a txt file containing sentences like:
When I move to this page
Then It display poup
......
......
so i want to get lines only contains "Then" keyword at starting using Regular Expression
Upvotes: 1
Views: 775
Reputation: 101731
This can be easily done using string.StartsWith
method via LINQ:
var lines = File.ReadLines("path")
.Where(line => line.StartsWith("Then"))
.ToList();
Upvotes: 2
Reputation: 25370
You don't want or need Regex for this:
var lines = File.ReadAllLines(filePath).Where(l => l.StartsWith("Then"));
Upvotes: 1