Hello
I have a code
And logicaly I want to write
to find TeNam or Trrr or Tormnew in a string, but I dont know how to do it syntaxicaly
Could you help me?
I have a code
And logicaly I want to write
C#:
string pattern = @"\b(TeNam, Trrr, Tormnew)\b";
C#:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.IO;
using System.Text.RegularExpressions;
namespace ConsoleApp1
{
class Program
{
static void Main(string[] args)
{
string rootFolder = @"C:\Users\lavraschuk\Desktop\Tdd\Test";
string pattern = @"\b(TeNam)\b";
foreach (var file in Directory.EnumerateFiles(rootFolder, "*.txt", SearchOption.AllDirectories))
{
using (StreamReader sr = new StreamReader(file, System.Text.Encoding.Default))
{
string line;
while ((line = sr.ReadLine()) != null)
{
if (Regex.IsMatch(line, pattern, RegexOptions.IgnoreCase))
Console.WriteLine(file+ " " + line);
}
}
}
Console.ReadKey();
}
}
}
Could you help me?
Last edited by a moderator: