I'm using C# interactive, and here is the setup:
#r "System.Text.RegularExpressions"
using System.Text.RegularExpressions;
string s = "Number 42" + Environment.NewLine + "and 1 number 3";
I'm looking to add brackets around all numbers at the end of a line, or at end of string (42 and 3 should both get brackets).
Note: on my system
Environment.NewLineis\r\n
So I try Regex.Replace(s, "(\\d+)$", "[$0]", RegexOptions.Multiline) and only the 3 gets wrapped.
If I do Regex.Replace(s, "(\\d+)\r?$", "[$0]", RegexOptions.Multiline) both get wrapped but one has an extra \r inside the brackets. So the regex engine is believing the lie that Environment.NewLine is \n.
Is there a separate Environment.NewLine setting just for regexes? If so, how do I set it?
