2011/7/10 Mykyta Yevstifeyev:
That can be simplified to: !^ftp://([^@]*@)?([^:/?#]*).*$!\\2!i
I agree with you here. Yet, actually this may be simplified far to
!^ftp://(.*@)?([^:/?#]*).*$!\\2!i
Is "anything ending with '@'" (in your version) the same as "any non-'@' ending with the first '@'" (in JimC's version)? For clarity I'd prefer the first version, but maybe we are not yet ready:
"@" chars are not generally allowed in in <userinfo> without percent encoding, as well as in other parts of the URI.
As soon as you are behind the <userinfo> in an <authority> it is not more necessary to percent-encode '@'. I'm too lazy to check it, but I guess that '@' is an ordinary <pchar>, and also allowed in query parts and fragments. After all mailto: and news: URLs use '@' for their purposes outside of <userinfo>. Therefore we might need something in the direction of... !^ftp://([^@/?#]*@)?([^:/?#]*).*$!\\2!i ...matching '@' only before any path or query or fragment. [^@/?#]* should match the colon in a user:pass <userinfo>. -Frank