日期:2014-05-19  浏览次数:20889 次

求一正则表达式,并希望大家能介绍几本关于其的好书!谢谢了
exchange/mediamart/Outdoor_detail.asp?mediaid=116
求一正则表达式把Outdoor_detail提取出来,高分答谢!

------解决方案--------------------
不用正则:
string s1 = s.SubString(IndexOfLast( "\/ ",s.IndexOf( "\? ")-s.IndexOfLast( "\/ ");

------解决方案--------------------
string sourceString = "/Exchange/MediaMart/regie-shop/My_media_list.asp?user_id=11687 ";
Match result = Regex.Match(sourceString,@ "[\s\S]*/([^\?]*) ");
if(result.Success)
{
WL(result.Groups[1].Value);
}

//////////////////////////////////////////////
MSN:bdbox@hotmail.com请给我一个与您交流的机会!
------解决方案--------------------
不需用正则,用个函数就可以了。
Path.GetFileNameWithoutExtension( "exchange/mediamart/Outdoor_detail.asp?mediaid=116
");
------解决方案--------------------
string url=Console.ReadLine();
Regex r1=new Regex(@ "(? <=/)(? <Text> [^./]*).*?(?=\?) ",RegexOptions.RightToLeft);
Console.WriteLine(r1.Match(url).Groups[ "Text "].Value);
------解决方案--------------------
Title:Mastering Regular Expressions
URL:http://www.amazon.com/exec/obidos/tg/detail/-/1565922573
ISBN:1565922573
Author:Jeffrey E. F. Friedl
Publisher:O 'Reilly & Associates
Page:342 pages
Edition:1st edition (January 15, 1997)
Catalog:Computer Bks - Languages / Programming
Format:PDF
Size:5.79 MB
Supplier:Unknown
Summary:Regular expressions are a central element of UNIX utilities like egrep and programming languages such as Perl. But whether you 're a UNIX user or not, you can benefit from a better understanding of regular expressions since they work with applications ranging from validating data-entry fields to manipulating information in multimegabyte text files. Mastering Regular Expressions quickly covers the basics of regular-expression syntax, then delves into the mechanics of expression-processing, common pitfalls, performance issues, and implementation-specific differences. Written in an engaging style and sprinkled with solutions to complex real-world problems, Mastering Regular Expressions offers a wealth information that you can put to immediate use.

看MSDN上的也够用了
------解决方案--------------------
(? <=/)(\w+)(?=\.)
------解决方案--------------------
string text= "exchange/mediamart/Outdoor_detail.asp?mediaid=116 ";
Match textMatch=Regex.Match(text,@ "(? <=/)(\w*)(?=\.) ");