正则取内容(很简单的)

hq2008 2007-02-07 05:24:42
内容:

string aa="Who Sub: aa.bb.cc<br><br><br>sdlfjdslfjdsfldsjflsdjf...";

取出以下结果(要用正则实现,注意:是Who Sub:到第一个<br>之间的内容,":"后面有没有空格不确定)

aa.bb.cc

说一下我用以下的怎么不能取出:
Match m=Regex.Match(aa,"Who Sub:(.*)?[^<br>]");
Match m=Regex.Match(aa,"(?<=Who Sub:)[\\w\\.]+[^<br>]");
Console.Write(m.Groups[1].ToString());
...全文
237 6 打赏 收藏 转发到动态 举报
AI 作业
写回复
用AI写文章
6 条回复
切换为时间正序
请发表友善的回复…
发表回复
xiajian19820809 2007-02-07
  • 打赏
  • 举报
回复
介绍三个C#技术群:
C#程序员在长沙1 群号:15283069
C#程序员在长沙2 群号:8689365
C#程序员在长沙3 群号:15082848
hq2008 2007-02-07
  • 打赏
  • 举报
回复
就是取出下面的的"Whois Server: whois.networksolutions.com"中的whois.networksolutions.com

"<br>Whois Server Version 1.3<br><br>Domain names in the .com and .net domains can now be registered<br>with many different competing registrars. Go to http://www.internic.net<br>for detailed information.<br><br> Domain Name: SOHU.COM<br> Registrar: NETWORK SOLUTIONS, LLC.<br> Whois Server: whois.networksolutions.com<br> Referral URL: http://www.networksolutions.com<br> Name Server: NS3.SOHU.COM<br> Name Server: NS1.SOHU.COM<br> Name Server: NS2.SOHU.COM<br> Status: clientTransferProhibited<br> Updated Date: 31-jan-2007<br> Creation Date: 05-jul-1998<br> Expiration Date: 04-jul-2009<br><br><br>>>> Last update of whois database: Tue, 6 Feb 2007 16:00:38 EST <<<<br><br>NOTICE: The expiration date displayed in this record is the date the<br>registrar's sponsorship of the domain name registration in the registry is<br>currently set to expire. This date does not necessarily reflect the expiration<br>date of the domain name registrant's agreement with the sponsoring<br>registrar. Users may consult the sponsoring registrar's Whois database to<br>view the registrar's reported date of expiration for this registration.<br><br>TERMS OF USE: You are not authorized to access or query our Whois<br>database through the use of electronic processes that are high-volume and<br>automated except as reasonably necessary to register domain names or<br>modify existing registrations; the Data in VeriSign Global Registry<br>Services' (\"VeriSign\") Whois database is provided by VeriSign for<br>information purposes only, and to assist persons in obtaining information<br>about or related to a domain name registration record. VeriSign does not<br>guarantee its accuracy. By submitting a Whois query, you agree to abide<br>by the following terms of use: You agree that you may use this Data only<br>for lawful purposes and that under no circumstances will you use this Data<br>to: (1) allow, enable, or otherwise support the transmission of mass<br>unsolicited, commercial advertising or solicitations via e-mail, telephone,<br>or facsimile; or (2) enable high volume, automated, electronic processes<br>that apply to VeriSign (or its computer systems). The compilation,<br>repackaging, dissemination or other use of this Data is expressly<br>prohibited without the prior written consent of VeriSign. You agree not to<br>use electronic processes that are automated and high-volume to access or<br>query the Whois database except as reasonably necessary to register<br>domain names or modify existing registrations. VeriSign reserves the right<br>to restrict your access to the Whois database in its sole discretion to ensure<br>operational stability. VeriSign may restrict or terminate your access to the<br>Whois database for failure to abide by these terms of use. VeriSign<br>reserves the right to modify these terms at any time.<br><br>The Registry database contains ONLY .COM, .NET, .EDU domains and<br>Registrars.<br>"
hq2008 2007-02-07
  • 打赏
  • 举报
回复
Who Sub:(?<test>.+)<br>与我Match m=Regex.Match(aa,"Who Sub:(.*)?[^<br>]");这个不是一样的结果吗?我要的是只取出Who Sub:到第一个<br>之间的内容,第二个<br>第三个<br>是不要的,以上的会取出所有的<br>的,那这个问题就没有什么啦
hq2008 2007-02-07
  • 打赏
  • 举报
回复
又碰到啦,cpp2017(慕白兄)你有没有测试,好像不行
cpp2017 2007-02-07
  • 打赏
  • 举报
回复
string aa = "Who Sub: aa.bb.cc<br><br><br>sdlfjdslfjdsfldsjflsdjf..."; Regex reg = new Regex(@"^Who Sub:([\s\S]*?)<br>"); MatchCollection ms = reg.Matches(aa); if (ms.Count > 0) { Response.Write(ms[0].Result("$1")); }
laodeng72586 2007-02-07
  • 打赏
  • 举报
回复
Who Sub:(?<test>.+)<br>

62,243

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术交流专区
javascript云原生 企业社区
社区管理员
  • ASP.NET
  • .Net开发者社区
  • R小R
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

.NET 社区是一个围绕开源 .NET 的开放、热情、创新、包容的技术社区。社区致力于为广大 .NET 爱好者提供一个良好的知识共享、协同互助的 .NET 技术交流环境。我们尊重不同意见,支持健康理性的辩论和互动,反对歧视和攻击。

希望和大家一起共同营造一个活跃、友好的社区氛围。

试试用AI创作助手写篇文章吧