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 -

xslt - Umbraco and EXSLT sets do not work -

php - How can I merge Nodes & Webform Submissions into instances of one general Content Type in Drupal 6? -