I'm doing some URL validation and want to match http, https, ftp, ftps, sftp etc.
So far I have /(https?|ftps?)/
.. If I use s?ftps?
it'll match ftp, ftps, sftp and sftps.
What's the best way to get around this? (sftps is not a valid URL scheme)
Try this:
/(ht|f)tps?|sftp/
Should work.
This should cover all your bases...
/(ht|f)tps?|sftp/
You can use:
/^(?:ht|f)tps?|sftp/
or
/^(?!sftps)(?:https?|s?ftps?)/