I want to go through a list of header files, and save the files which those include. My problem is that the pattern does not match.
In this link you can find the pattern which I thought will work: https://regex101.com/r/jbJLxT/3
string rgxPat = "\\#include\\s+\"(?:\\w+\\/)*(\\w +\\.(?:hed|he|hdb|h))\"";
Regex incLRgx = new Regex(rgxPat, RegexOptions.IgnoreCase);
for (int i = alrdyChckd; i < missFiles.Count; i++)
{
tmpStr = baseSBFolder + "\\" + missFiles[i].getPath() + "\\" + missFiles[i].getName();
System.IO.StreamReader actFile = new System.IO.StreamReader(tmpStr);
while((actLine = actFile.ReadLine()) != null)
{
Match match = incLRgx.Match(actLine);
if(match.Success)
{
missFiles.Add(baseSB.getFileByName(match.Groups[1].Value.ToString()));
}
}
alrdyChckd++;
}
I checked the debug varaibles and the match function always give back false return value, while the pattern and the actual line seems to be the same. Also it's a problem that I cannot add double qoutes as I wanted with the string = @"[pettern]" form because the double queste will close the pattern.
using/IDisposablefor yourStreamReaderand alsoPath.Combine()instead of all that string concatenation with hard-coded `\`.\wand+. Replace\\/with/in the C# code.match.Groups[1].Value.ToString()=match.Groups[1].Value