Given a file that contains code, my program reads the file using stream reader, and places it into a string. so for this file:
class A{
public void foo()
{
r="asdastest@asdf.com";
s="*asasdddsaa@test.asdf.com";
t="@asdf.com";
u="@pas.asdf.com nwe asda";
}
}
The string is:
"class A{\r\n \r\n public void foo()\r\n {\r\n r=\"asdastest@asdf.com\";\r\n s=\"*asasdddsaa@test.asdf.com\";\r\n t=\"@asdf.com\";\r\n u=\"@pas.asdf.com nwe asda\";\r\n }\r\n}\r\n\r\n\r\n"
(ignore \t which are replaced by " ").
I get a regular expression as an input,the regular expression uses the "$" to find a statement "before CRLF".
The input regex is: (?i)\u0040.{0,10}asdf\u002Ecom($|\s|\W).*
However when I execute the regex on the text- it finds only one result.
If I add "enter" instead of one of the \r\n in the string that represents the code, the additional result will show.
Since I cannot modify the regex, how can I read the file and get the 4 results i would expect?
The code that reads the file is:
using (StringReader sr = new StringReader(ParsingHelpers.ReadFromFile(FilesExtensions.Instance, Configuration.Implementation.Configuration.Instance, LogEngineWriter.GetInstance(), curFile, "FindByRegex")))
{
string bla=sr.ReadToEnd();
bla=bla.Replace("\t", " ");
fileStrBuilder.Append(bla);
}
The regex execution is a regular Match of the regex I wrote with Multiline and single line. The match result is:
@asdf.com\";\r\n s=\"*asasdddsaa@test.asdf.com\";\r\n t=\"@asdf.com\";\r\n u=\"@pas.asdf.com nwe asda\";\r\n }\r\n}\r\n\r\n\r\n"