use the classes in System.Text.RegularExpressions, for exampleusing System;
using System.Text.RegularExpressions; string s = @"<input type=text id=acb>
<input type=""file"" onpropertychange=xxx value=yyy>
<TEXTAREA>[...]
abc</TEXTAREA>
";
Regex re = new Regex(@"<input(?<input1>[^>]+)>\s*<input type=""file""(?<input2>[^>]+)>\s*<TEXTAREA[^>]*>(?<textarea>.*?)</TEXTAREA>",RegexOptions.IgnoreCase | RegexOptions.Singleline);
Match m = re.Match(s);
if (m.Success)
{
Console.WriteLine("input:{0}\ninput2:{1}\ntextarea:{2}",
m.Groups["input1"].Value,
m.Groups["input2"].Value,
m.Groups["textarea"].Value);
}
using System.Text.RegularExpressions; string s = @"<input type=text id=acb>
<input type=""file"" onpropertychange=xxx value=yyy>
<TEXTAREA>[...]
abc</TEXTAREA>
";
Regex re = new Regex(@"<input(?<input1>[^>]+)>\s*<input type=""file""(?<input2>[^>]+)>\s*<TEXTAREA[^>]*>(?<textarea>.*?)</TEXTAREA>",RegexOptions.IgnoreCase | RegexOptions.Singleline);
Match m = re.Match(s);
if (m.Success)
{
Console.WriteLine("input:{0}\ninput2:{1}\ntextarea:{2}",
m.Groups["input1"].Value,
m.Groups["input2"].Value,
m.Groups["textarea"].Value);
}
解决方案 »
- C#后台关闭当前页面
- 怎么写鼠标滚轮事件?
- 如何访问IE文件夹,并枚举出来?
- listview中数据大小的判断
- 巨菜的窗体设计器问题,快来抢分阿
- WINFORM如何绑定listbox combobox控件。
- 畫[曲線圖][柱狀]代碼[有錯誤]正在改正中....哪位願意改的也下載下來改改吧!!改好了的話也會共享給大家的
- Socket.Receive(byte[])函数,如果参数byte[]的大小已定,而要收到的数据包比它大,将会如何?
- c#的登录代码除了这样写,还有其他方法吗???请赐教
- 问一个临时文件的问题?
- 请教如何用session取得当前的登录用户名??
- .net中如何像Delphi里那样编写VCL控件,包括发布事件,属性编辑器,注册等
using System.Text.RegularExpressions;class TestReg
{ static void Main()
{
string s = @"<input type=text id=acb>
<input type=""file"" onpropertychange=xxx value=yyy>
<TEXTAREA>[...]
abc</TEXTAREA>
";
Regex re = new Regex(@"<input(?<input1>[^>]+)>\s*<input type=""file""(?<input2>[^>]+)>\s*<TEXTAREA[^>]*>(?<textarea>.*?)</TEXTAREA>",RegexOptions.IgnoreCase | RegexOptions.Singleline);
Match m = re.Match(s);
if (m.Success)
{
Console.WriteLine("input:{0}\ninput2:{1}\ntextarea:{2}",
m.Groups["input1"].Value,
m.Groups["input2"].Value,
m.Groups["textarea"].Value);
}
}
}
then compile itcsc TestReg.cs
F:\csharp>notepad TestReg.csF:\csharp>csc TestReg.cs
Microsoft (R) Visual C# .NET Compiler version 7.10.3052.4
for Microsoft (R) .NET Framework version 1.1.4322
Copyright (C) Microsoft Corporation 2001-2002. All rights reserved.
F:\csharp>TestReg
input: type=text id=acb
input2: onpropertychange=xxx value=yyy
textarea:[...]
abcF:\csharp>