0

I want to search for a specific (variable) word in a file.

private int read_inv(string file, string part) // part = SCRAP
{
    string text = File.ReadAllText(invFolder + file + ".inv");


    string find = @"(?i)\bSCRAP\b"; // this return 3 like it should be
    string find = @"(?i)\b"+part+"\b"; // this return 0

    Regex r = new Regex(find);
    MatchCollection matches = r.Matches(text);
    int iCount = matches.Count;

    return matches.Count;
} 
Tomasz Juszczak
  • 2,276
  • 15
  • 25
manuel
  • 11
  • 1

0 Answers0