📄 class1.cs
字号:
using System;
using System.Text.RegularExpressions;
namespace RXOptions
{
class RXOptionsApp
{
public static void PrintMatches(Regex r)
{
Console.WriteLine();
string s = "The KING Was In His Counting House";
MatchCollection mc = r.Matches(s);
for (int i = 0; i < mc.Count; i++)
{
Console.WriteLine(
"Found '{0}' at position {1}",
mc[i].Value, mc[i].Index);
}
}
[STAThread]
static void Main(string[] args)
{
Regex r = new Regex("in|In|IN|iN"); // same
PrintMatches(r);
r = new Regex("in", RegexOptions.IgnoreCase);
PrintMatches(r);
r = new Regex("in",
RegexOptions.IgnoreCase |
RegexOptions.RightToLeft);
PrintMatches(r);
r = new Regex(
@"in # this is the first pattern to match
|[aeiou]s # or any vowel followed by 's'
", RegexOptions.IgnorePatternWhitespace);
PrintMatches(r);
r = new Regex("in", RegexOptions.Compiled);
PrintMatches(r);
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -