By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
454,405 Members | 1,691 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 454,405 IT Pros & Developers. It's quick & easy.

regexp help

P: n/a
hi i have this function to verify a valid url:

$regexp =
"^(https?://)?(([0-9a-z_!~*'().&=+$%-]+:)?[0-9a-z_!~*'().&=+$%-]+@)?(([0-9]{1,3}\.){3}[0-9]{1,3}|([0-9a-z_!~*'()-]+\.)*([0-9a-z][0-9a-z-]{0,61})?[0-9a-z]\.[a-z]{2,3})(:[0-9]{1,4})?((/?)|(/[0-9a-z_!~*'().;?:@&=+$,%#-]+)+/?)$";

but it wont work with .info domains. can anyone tell me whats wrong ?


Jul 17 '05 #1
Share this Question
Share on Google+
2 Replies


P: n/a
On 2005-05-04, Yang <ya******@sympatico.ca> wrote:
hi i have this function to verify a valid url:

$regexp =
"^(https?://)?(([0-9a-z_!~*'().&=+$%-]+:)?[0-9a-z_!~*'().&=+$%-]+@)?(([0-9]{1,3}\.){3}[0-9]{1,3}|([0-9a-z_!~*'()-]+\.)*([0-9a-z][0-9a-z-]{0,61})?[0-9a-z]\.[a-z]{2,3})(:[0-9]{1,4})?((/?)|(/[0-9a-z_!~*'().;?:@&=+$,%#-]+)+/?)$";

but it wont work with .info domains. can anyone tell me whats wrong ?


You forgot to post the function.
At first sight, i would suggest to change your regular expression that
it allows up to 4 characters in the [a-z] class instead of the 3 now.

But i think you'll be better of with searching the web for a more
complete expression. Or write it yourself.
--
Met vriendelijke groeten,
Tim Van Wassenhove <http://www.timvw.info>
Jul 17 '05 #2

P: n/a
Yang wrote:
hi i have this function to verify a valid url:
That would be an enormous function, if you could write it.
$regexp =
"^(https?://)?(([0-9a-z_!~*'().&=+$%-]+:)?[0-9a-z_!~*'().&=+$%-]+@)?
(([0-9]{1,3}\.){3}[0-9]{1,3}|([0-9a-z_!~*'()-]+\.)*([0-9a-z][0-9a-z-]
{0,61})?[0-9a-z]\.[a-z]{2,3})(:[0-9]{1,4})?((/?)|(/[0-9a-z_!~*'().;?:
@&=+$,%#-]+)+/?)$";
Where are you after finding *that* one?

A different RE comes along every month or so. URIs, e-mail addresses,
postcodes, telephone numbers, and so on, you name it, even personal
names, believe it or not. It's interesting to see what people think
the possible forms of these things are.
but it wont work with .info domains.
I'd go further and say it won't work full stop -- for any useful notion
of 'work', that is.
can anyone tell me whats wrong ?


Fire it into The Regex Coach and it'll disect the pattern for you.
With a little understanding of RE syntax you should be able to make
sense of it; if on the other hand REs look Greek to you, then you won't
be able to make head nor tail of it.

http://www.php.net/manual/en/referen...ern.syntax.php

--
Jock

Jul 17 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.