📄 sample46.cs
字号:
namespace apiBook
{
using System;
using System.Text;
using System.Text.RegularExpressions;
public class TestMatchClass
{
public static void Main()
{
Regex testRegex=new Regex("href\\s*=\\s*(?:\"(?<1>[^\"]*)\"|(?<1>\\S+))");
string s="href=\"//www.apibook.com/data/css/v11/r1.css\"";
Match testMatch;
for (testMatch= testRegex.Match(s) ;testMatch.Success; testMatch =testMatch.NextMatch())
//使用NextMatch方法
{
Console.WriteLine("Found href " + testMatch.Groups[1] + " at "
+ testMatch.Groups[1].Index);
}
testRegex=new Regex("time:\\b(?<month>\\d{1,2})/(?<day>\\d{1,2})/(?<year>\\d{2,4})\\b");
s="time:02/01/2004";
for (testMatch= testRegex.Match(s) ;testMatch.Success; testMatch =testMatch.NextMatch())
{
Console.WriteLine("Found time " + testMatch.Groups[1] + " at "
+ testMatch.Groups[1].Index);
}
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -