RegEx for parsing FTP LIST command

Need to parse the FTP LIST command output? I did. Here’s what I came up with, its based on another post that didn’t quite work for me. The code below works specifically on the FilZilla FTP Server which I was targetting.


^(?<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{2})s+(?<year>d{4})))s+(?<name>.+)$

One thought on “RegEx for parsing FTP LIST command

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.