.*
is short for
[^\r\n]*
So if we combine these
[.\r\n]*
why dont we get regexp that matches every string in the world?
Like most other special characters in regular expressions, when a .
appears withing a character class it represents a literal .
character. If you want to match all characters a common technique is to use something like this:
[\s\S]*
Or alternatively you can use RegexOptions.Singleline
to specify that .
should match all characters and just use:
.*
For example:
var input = "foo\r\nbar";
var match = Regex.Match(input, ".*", RegexOptions.Singleline);
Assert.AreEqual(input, match.Value);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With