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

Popular posts from this blog

c++ - Compiling static TagLib 1.6.3 libraries for Windows -

PostgreSQL 9.x - pg_read_binary_file & inserting files into bytea -

asp.net - call stack missing info on mono with apache and mod_mono -