日期:2014-05-20  浏览次数:20515 次

帮忙写个正则表达式啊
-----------------------------9040894219264
Content-Disposition: form-data; name="__VIEWSTATE"

/wEPDwUKMTI3MTMxMTcxNw9kFgICAw8WAh4HZW5jdHlwZQUTbXVsdGlwYXJ0L2Zvcm0tZGF0YWRk/WMD713TWnSEdUEAgt40yVOsrRk=
-----------------------------9040894219264
Content-Disposition: form-data; name="__EVENTVALIDATION"

/wEWAgKbvJTbBgKM54rGBlF65U36PvzwLPhnamNIfpNsMK5X
-----------------------------9040894219264
Content-Disposition: form-data; name="FileUpload100"; filename="js.txt"
Content-Type: text/plain
\r\n\r\n\r\n\r\n
var ln = new Array();var country = new Array();var seasons = new Array();var js_lid = new Array();
ln[1]=[92,34,39,93,85,165,469,196,180,190,103,105,552,472,471,223,521,363,210,219,247,104,468,384,470,100,457,197,99,131,355,217,421,194,308,290,518,183,76,195,181,305,193,130,542,88,204,221,293,239,800,473];
js_lid[92][22]=['545','????????','2','lgimg/545.jpg'];sacdasfjblkvbcvbksd;gkl;gsdgswreg--*-*/**/-???
-----------------------------9040894219264
Content-Disposition: form-data; name="Button1"
\r\n\r\n
??????
-----------------------------9040894219264--

我要取
Content-Disposition: form-data; name="FileUpload100"; filename="js.txt"
Content-Type: text/plain
到第一个-----------------------------9040894219264
之间的内容啊 这个开头和结尾已经确定了 就是中间的内容什么字符都可能出现 哪位大写帮我解决下?
filename 我已经取到了 只要能帮我之间的内容就行了 感激不尽啊。没分了 见谅啊。


------解决方案--------------------
Content-Disposition: form-data; name=\"([^"]+)\"; filename=\"([^"]+)\"\n
------解决方案--------------------
Content-Disposition: form-data; name=\"FileUpload100\"; filename=\"js\.txt\"
Content-Type: text/plain.+9040894219264


------解决方案--------------------
C# code
            string str = @"-----------------------------9040894219264
Content-Disposition: form-data; name=""__VIEWSTATE""

/wEPDwUKMTI3MTMxMTcxNw9kFgICAw8WAh4HZW5jdHlwZQUTbXVsdGlwYXJ0L2Zvcm0tZGF0YWRk/WMD713TWnSEdUEAgt40yVOsrRk=
-----------------------------9040894219264
Content-Disposition: form-data; name=""__EVENTVALIDATION""

/wEWAgKbvJTbBgKM54rGBlF65U36PvzwLPhnamNIfpNsMK5X
-----------------------------9040894219264
Content-Disposition: form-data; name=""FileUpload100""; filename=""js.txt""
Content-Type: text/plain
\r\n\r\n\r\n\r\n
var ln = new Array();var country = new Array();var seasons = new Array();var js_lid = new Array();
ln[1]=[92,34,39,93,85,165,469,196,180,190,103,105,552,472,471,223,521,363,210,219,247,104,468,384,470,100,457,197,99,131,355,217,421,194,308,290,518,183,76,195,181,305,193,130,542,88,204,221,293,239,800,473];
js_lid[92][22]=['545','????????','2','lgimg/545.jpg'];sacdasfjblkvbcvbksd;gkl;gsdgswreg--*-*/**/-???
-----------------------------9040894219264
Content-Disposition: form-data; name=""Button1""
\r\n\r\n
??????
-----------------------------9040894219264--";
            Regex reg = new Regex(@"(?is)(?<=filename=""[^""]+""\s*Content-Type:\s*text/plain).*?(?=(?:---?)+\d+)");
            Console.WriteLine(reg.Match(str).Value);

------解决方案--------------------
Content-Disposition: form-data; name=\"(?:[^"]+)\"; filename=\"(?:[^"]+)\"\nContent-Type: text/plain([\s\S]*?)-----------------------------9040894219264