-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathBetween.cs
35 lines (29 loc) · 1019 Bytes
/
Between.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.VisualStudio.TestTools.UnitTesting;
namespace StringExtensions.Examples
{
[TestClass]
[TestCategory("Examples")]
public class AllBetweenExample
{
[TestMethod]
public void Example1()
{
// This sample simply gets data surrounded by stars
string sample = "i *am* surrounded and so am *i*";
IEnumerable<string> quotedParts = sample.AllBetween('*');
CollectionAssert.AreEqual(new[] { "am", "i" }, quotedParts.ToArray());
}
[TestMethod]
public void Example2()
{
// this sample gets data surrounded by block quotes (2 different signs)
string sample = "Look [i] am surrounded just [like] you";
IEnumerable<string> quotedParts = sample.AllBetween('[', ']');
CollectionAssert.AreEqual(new[] { "i", "like" }, quotedParts.ToArray());
}
}
}