mIRC Home    About    Download    Register    News    Help

Print Thread
#224729 16/08/10 11:14 PM
Joined: Sep 2007
Posts: 202
F
firefox Offline OP
Fjord artisan
OP Offline
Fjord artisan
F
Joined: Sep 2007
Posts: 202
was hoping to use isalnum to quickly validate a url - i.e. url has letters and numbers in it but seems alnum doesn't accept punctuation

how do I check if a %var has letters, numbers and punctuation it?

firefox #224730 16/08/10 11:24 PM
Joined: Oct 2003
Posts: 3,918
A
Hoopy frood
Offline
Hoopy frood
A
Joined: Oct 2003
Posts: 3,918
A regex. Specifically /^[[:alpha:][:digit:][:punct:]]+$/

Of course that answers your question, but it's not a good way to validate a URL. URL's are not just made up of arbitrary alphanum and punctuation characters.


- argv[0] on EFnet #mIRC
- "Life is a pointer to an integer without a cast"
firefox #224732 16/08/10 11:32 PM
Joined: Jul 2007
Posts: 1,129
T
Hoopy frood
Offline
Hoopy frood
T
Joined: Jul 2007
Posts: 1,129
Like argv0 said, regex is the best option:
Code:
  var %d = com|edu|gov|mil|net|org|biz|info|name|museum|us|ca|uk
  var %url = /(?<=^|\s)((?>\S{3,8}:\/\/|w{3}\56)\S+)|\56( $+ %d $+ )\b/iS
  if ($regex($1-,%url)) { ;do something

Tomao #224737 17/08/10 03:41 AM
Joined: Sep 2007
Posts: 202
F
firefox Offline OP
Fjord artisan
OP Offline
Fjord artisan
F
Joined: Sep 2007
Posts: 202
well it is a specific set of url's for one site

but yes I think regex would be better

thanks for the suggestions


Link Copied to Clipboard