Okay guys, this is my first post, but I've used info from these forums in the past and you guys kick ass!
Here is my question:
I have a logon script that maps drives and printers, and I want make certain that the passed server references are FQDNs. So, I need a way to take a string and see if its a FQDN based on these rules:
1) The whole string can't be more than 255 characters.
2) Individual labels can't be more than 63 characters. (labels are the stuff between the ".'s")
3) Each label must begin with a letter.
4) Each label must end with a letter or number
5) The letters in between in a label can be numbers, letters, or hyphens (no underscores).
6) Case doesn't matter.
7) Can't contain any whitespace.
8) Can be no trailing "." at the end of the whole string (this is debatable, but its what we do internally).
Now I'm no newbie to regular expressions. I have used them a bunch when scripting in a Unix environment. But, I'm having a hard time with the vbscript syntax. I decided to start with the label portion of the RegExp, and what I have so far works as long as the label has more than 1 letter. Having a single letter label is valid for FQDNs, so I have to find a way to fix this...
So, I set up my RegExp like this:
Dim regExp
Set regExp = New RegExp
With regExp
.Pattern = "(((^[a-zA-Z])([a-zA-Z0-9]|-)*)+)(\w$){1,63}"
.IgnoreCase = True
.Global = True
End With
I then use the Test method to test out my passed server name. As I said, everything is fine until I reduce it to a single letter name, but then it breaks down...
Any help would be great!
Here is my question:
I have a logon script that maps drives and printers, and I want make certain that the passed server references are FQDNs. So, I need a way to take a string and see if its a FQDN based on these rules:
1) The whole string can't be more than 255 characters.
2) Individual labels can't be more than 63 characters. (labels are the stuff between the ".'s")
3) Each label must begin with a letter.
4) Each label must end with a letter or number
5) The letters in between in a label can be numbers, letters, or hyphens (no underscores).
6) Case doesn't matter.
7) Can't contain any whitespace.
8) Can be no trailing "." at the end of the whole string (this is debatable, but its what we do internally).
Now I'm no newbie to regular expressions. I have used them a bunch when scripting in a Unix environment. But, I'm having a hard time with the vbscript syntax. I decided to start with the label portion of the RegExp, and what I have so far works as long as the label has more than 1 letter. Having a single letter label is valid for FQDNs, so I have to find a way to fix this...
So, I set up my RegExp like this:
Dim regExp
Set regExp = New RegExp
With regExp
.Pattern = "(((^[a-zA-Z])([a-zA-Z0-9]|-)*)+)(\w$){1,63}"
.IgnoreCase = True
.Global = True
End With
I then use the Test method to test out my passed server name. As I said, everything is fine until I reduce it to a single letter name, but then it breaks down...
Any help would be great!