Regular Expressions 101

Community Patterns

Community Library Entry

2

Regular Expression
PCRE (PHP <7.3)

/
(?<protocol>s?ftp):\/\/(?:(?<user>[^@\s]+)@)?(?<host>[^\?\s\:]+)(?:\:(?<port>[0-9]+))?(?:\?(?<password>.+))?
/
g

Description

Parse an SFTP or FTP url and brak it into named capture groups.

Submitted by Cullen Johnson - 10 years ago