我有这个正则表达式
"\\\"([^\"]*)\\\""
返回所有目录。 但我只想要有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
答案 0 :(得分:0)
只需输入应返回以.xml结尾的所有文件的new Regex("\"([^\"]+\\.xml)\"")
。