A
angie
how can i validate a field for a valid URL?? is ther any naming
conventions for it?
conventions for it?
how can i validate a field for a valid URL?? is ther any naming
conventions for it?
angie a écrit :
Same as for your question about identifying the IP address.
You can check again a regex (there are many already done out there).
A good starting point is:http://regexlib.com/DisplayPatterns.aspx?cattabindex=1&categoryId=2
Except that a regular expression which accepts all syntactically
valid URL's, and rejects all syntactically invalid ones, is far
from trivial; the one you cite, for example, will reject a lot
of legal URL's ("for example, and
accept a few illegal ones (e.g. "www."). I pretty sure it can
be done with a regular expression, but it will take a bit of
work to get it right.
(Note too that different types of URL's
may have slightly different syntax. If the protocol is
"mailto", for example, a '@' is required at one point, whereas
if it is "http", one may not appear unless quoted somehow (e.g.
"%40").
James Kanze a écrit :
Yes. That is why I provided the link to a regex library
instead of giving a specific regex. The site indicate what URI
are accepted or rejected depending on the regex used.
Or ftp that uses @ to separate the username/password from the actual
address:
ftp://john_dow[email protected]:245/path/to/data
Perhaps Boost.Spirit would be more fitting for capturing more
complex URI. At least It would be more manageable.
Want to reply to this thread or ask your own question?
You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.