列出在C#中只使用正则表达式的txt文件的目录

时间:2017-08-14 08:08:40

标签: c# regex winforms visual-studio-2012

我有这个正则表达式

"\\\"([^\"]*)\\\"" 

返回所有目录。 但我只想要有xyz.xml文件的目录

请有人帮助我。

 string url = //some url
                HttpWebRequest request = (HttpWebRequest)WebRequest.Create(url);
                request.Credentials = new NetworkCredential(username, password);

                using (HttpWebResponse response = (HttpWebResponse)request.GetResponse())
                {
                    using (StreamReader reader = new StreamReader(response.GetResponseStream()))
                    {
                        string html = reader.ReadToEnd();

                        Regex regex = new Regex("\\\"([^\"]*)\\\"");
                        //  Regex regex = new Regex("\\\"(xml)");
                        MatchCollection matches = regex.Matches(html);
                        if (matches.Count > 0)
                        {
                            foreach (Match match in matches)
                            {
                                if (match.Success)
                                {
                                 //further code

1 个答案:

答案 0 :(得分:0)

只需输入应返回以.xml结尾的所有文件的new Regex("\"([^\"]+\\.xml)\"")