Exemple #1
0
        public void Parse_XModeComment_FlagSet_IgnoresComment()
        {
            var regex = RegularExpression.From(
                new Regex("abc # This is a comment", RegexOptions.IgnorePatternWhitespace)
                ).ToRegex(RegexOptions.IgnorePatternWhitespace);

            Assert.IsTrue(regex.IsMatch("abc"));
        }
        public static void AssertRoundTrips(string regex, RegexOptions options = RegexOptions.None, string expected = null)
        {
            var result = RegularExpression.From(new Regex(regex, options)).ToRegex(options);

            Assert.AreEqual(expected ?? regex, result.ToString());
        }
Exemple #3
0
        public void Parse_XModeComment_FlagNotSet_InterpretedAsLiteral()
        {
            var regex = RegularExpression.From(new Regex("abc # This is a comment")).ToRegex();

            Assert.IsTrue(regex.IsMatch("abc # This is a comment"));
        }
Exemple #4
0
        public void Parse_InlineOptions_IgnoreWhitespace_StopsEscaping()
        {
            var regex = RegularExpression.From(new Regex(@"Yes escaping(?x)No escaping")).ToRegex();

            Assert.IsTrue(regex.IsMatch("Yes escapingNoescaping"));
        }