tags:

views:

36

answers:

1

Currently using:

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

How can i make http:// not compulsory but if it does exist, it must be written as http://

+3  A: 

Replace

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

by

^(?:(ht|f)tp(s?)\:\/\/)?
Jens
Beat me by 5 seconds - but yours is better anyway. I skipped the `(?:...`
Chris
Wrikken
@Wrikken: Yeah, I know. I did not want to change the capture group numbering, in case the OP relies on it somewhere...
Jens