Skip to content

RegexOptions.Multiline should be same as line by line #40566

@VS-ux

Description

@VS-ux

Using RegexOptions.Multiline should be the same as reading a file line by line I think.

When reading an entire file, and the Regexing it with RegexOptions.Multiline should be same as reading it line by line
Here is a code sample:

`
string path = @"PathToFile";
using (StreamReader reader = new StreamReader(path))
{
//string s = reader.ReadToEnd();
//int matchCount = Regex.Matches(s, @"^(.+)/([^/]+)$", RegexOptions.Compiled | RegexOptions.Multiline).Count; //I think this should be the same as below:

int matchCount = 0;
string s;
while ((s = reader.ReadLine()) != null)
{
    matchCount += Regex.Matches(s, @"^(.+)\/([^/]+)$", RegexOptions.Compiled).Count;
}

Console.WriteLine(matchCount);

}
`

This is probably related to #25598
This may be I'm just completely doing it wrong, and I apologize if this is very stupid.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions