regex - Regexp to grab protocol from URL -
let's have variable called url , it's assigned value of http://www.google.com
. can received url via ftp, hence it'll ftp://ftp.google.com
. how can have grab before :
? i'll have if/else condition afterwards test logic.
/^[^:]+/
if want prevent 'www.foobar.com' (which has no protocol specified) match protocol:
/^[^:]+(?=:\/\/)/
Comments
Post a Comment