本文整理汇总了C#中StringScanner.GetBoundedBy方法的典型用法代码示例。如果您正苦于以下问题:C# StringScanner.GetBoundedBy方法的具体用法?C# StringScanner.GetBoundedBy怎么用?C# StringScanner.GetBoundedBy使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类StringScanner
的用法示例。
在下文中一共展示了StringScanner.GetBoundedBy方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Bounded
public void Bounded()
{
scanner = @"<comment>How's complex bounding working?</comment> the end";
string text = scanner.GetBoundedBy("<comment>", "</comment>");
Assert.AreEqual(@"How's complex bounding working?", text, "Complex bounding worked");
Assert.AreEqual(' ', scanner.NextChar, "At the right place");
Assert.IsTrue(scanner.ExpectAlpha().ExpectAlpha().Finished, "At the end");
scanner = "some(complex(formula+2))";
scanner.ExpectAlpha();
text = scanner.GetBoundedBy('(', false);
Assert.AreEqual("complex(formula+2)", text, "OK with inner parens");
}
示例2: BuiltInSelectors
public void BuiltInSelectors()
{
[email protected]"someSelect[attr-bute= 'this ""is \' a quoted value']";
var text = scanner.Get(MatchFunctions.HTMLTagName);
Assert.AreEqual("someSelect", text, "Got first word");
StringScanner innerScanner = scanner.Get(MatchFunctions.BoundedWithQuotedContent);
Assert.IsTrue(scanner.Finished, "Outer scanner finished");
Assert.AreEqual(@"attr-bute= 'this ""is \' a quoted value'", innerScanner.Text, "Inner scanner text is right");
text = innerScanner.Get(MatchFunctions.HTMLAttribute);
Assert.AreEqual("attr-bute", text, "Got the attribute name");
innerScanner.Expect("=");
text = innerScanner.Get(MatchFunctions.Quoted);
Assert.AreEqual(@"this ""is ' a quoted value", text, "Quotes were dequoted");
Assert.IsTrue(innerScanner.Finished, "It's finished after we got the last text");
scanner = @"<comment>How's complex bounding working?</comment> the end";
text = scanner.GetBoundedBy("<comment>", "</comment>");
Assert.AreEqual(@"How's complex bounding working?", text, "Complex bounding worked");
Assert.AreEqual(' ', scanner.NextChar, "At the right place");
Assert.IsTrue(scanner.ExpectAlpha().ExpectAlpha().Finished, "At the end");
}