I compiled it in PHP, but it can be used in other languages. It's discouraged (for obvious reasons) but perfectly valid and should be anticipated. ) browsers sometimes translate HTTP authentication into the URL for subsequent [email protected], in a function in what language? In general, though, you'd probably be better off using a function that's supplied to you by your framework or another library. For example, there's Python's urlparse module, and in . Uri class's constructor as a means of validating the URL. If you need to check if it's actually valid, you'll eventually have to try to access whatever's on the other end. # fragment )$/i This modified version was not checked against the URI specification so I can't vouch for it's compliance, it was altered to handle URLs on local network environments and two digit TLDs as well as other kinds of Web URL, and to work better in the PHP setup I use. // auth requires @ ')((([a-z0-9]\.|[a-z0-9][a-z0-9-]*[a-z0-9]\.)*'.
:[a-z\u00a1-\uffff0-9]-*)*[a-z\u00a1-\uffff0-9] )*(? The actual URL syntax is pretty complicated and not easy to represent in regex. Most of the simple-looking regexes out there will give many false negatives as well as false positives. "h:" is valid prefix See w3.org/Addressing/URL/for details. Examples of valid URL: mailto:[email protected] you want filter Hypertext Transfer Protocol only, you need use /^ $/i regular expression var Reg Exp =/^(?