解析从FTP LIST命令响应(语法变化) [英] Parse response from FTP LIST command (syntax variations)

查看:914
本文介绍了解析从FTP LIST命令响应(语法变化)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

该FTP LIST命令显示当前工作目录下的所有文件和目录的列表。的问题是,它返回几种不同的格式取决于在服务器上。是否有人知道一个.NET库,能够解析最流行的格式?我是一个试试这个正则表达式,如果失​​败,尝试下一个正则表达式的方式确定。

解决方案

这是我一直在使用的FileZilla中服务器之一:

<$p$p><$c$c>^(?<dir>[\-ld])(?<permission>([\-r][\-w][\-xs]){3})\s+(?<file$c$c>\d+)\s+(?<owner>\w+)\s+(?<group>\w+)\s+(?<size>\d+)\s+(?<timestamp>((?<month>\w{3})\s+(?<day>\d{2})\s+(?<hour>\d{1,2}):(?<minute>\d{2}))|((?<month>\w{3})\s+(?<day>\d{1,2})\s+(?<year>\d{4})))\s+(?<name>.+)$

http://chrishaas.word$p$pss.com/2009/06/10/regex-for-parsing-ftp-list-command/

The FTP LIST command displays a listing of all the files and directories in the current working directory. The problem is, it returns several different formats depending on the server. Does anybody know of a .NET library that is able to parse the most popular formats? I am OK with a "try this regex, if it fails, try the next regex" approach.

解决方案

Here's the one that I've been using for a FileZilla server:

^(?<dir>[\-ld])(?<permission>([\-r][\-w][\-xs]){3})\s+(?<filecode>\d+)\s+(?<owner>\w+)\s+(?<group>\w+)\s+(?<size>\d+)\s+(?<timestamp>((?<month>\w{3})\s+(?<day>\d{2})\s+(?<hour>\d{1,2}):(?<minute>\d{2}))|((?<month>\w{3})\s+(?<day>\d{1,2})\s+(?<year>\d{4})))\s+(?<name>.+)$

http://chrishaas.wordpress.com/2009/06/10/regex-for-parsing-ftp-list-command/

这篇关于解析从FTP LIST命令响应(语法变化)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆