Regular expression for checking URL protocol

Currently used:

@"^(ht|f)tp(s?)\:\/\/[0-9a-zA-Z]([-.\w]*[0-9a-zA-Z])*(:(0-9)*)*(\/?)([a-zA-Z0-9\-\.\?\,\'\/\\\+&%\$#_]*)?$

How can I make http://it optional, but if it exists, it should be written ashttp://

+5
source share
1 answer

Replace

^(ht|f)tp(s?)\:\/\/

by

^(?:(ht|f)tp(s?)\:\/\/)?
+9
source

All Articles