Home All Groups Group Topic Archive Search About
Author
30 Apr 2006 5:43 PM
Ben
I am trying to validate a textbox in which the user enters the following -
"smtp.servername.com or .net or .org or .com.uk etc... and I cannot. I have
tried. The string is in the form xxxxx.xxxxxxx.xxx or xxxx.xxxxx.xxx.xx. Does
anyone have any idea how to validate this string.
VB2005

Author
30 Apr 2006 5:53 PM
pvdg42
"Ben" <B**@discussions.microsoft.com> wrote in message
news:6E18AFDE-5A22-4471-97C5-EF4274BFD47F@microsoft.com...
>I am trying to validate a textbox in which the user enters the following -
> "smtp.servername.com or .net or .org or .com.uk etc... and I cannot. I
> have
> tried. The string is in the form xxxxx.xxxxxxx.xxx or xxxx.xxxxx.xxx.xx.
> Does
> anyone have any idea how to validate this string.
> VB2005
>
You might consider a tutorial such as these...

http://www.grymoire.com/Unix/Regular.html

http://www.zvon.org/other/PerlTutorial/Output/contents.html
Author
30 Apr 2006 6:41 PM
Homer J Simpson
"Ben" <B**@discussions.microsoft.com> wrote in message
news:6E18AFDE-5A22-4471-97C5-EF4274BFD47F@microsoft.com...
> I am trying to validate a textbox in which the user enters the following -
> "smtp.servername.com or .net or .org or .com.uk etc... and I cannot. I
> have
> tried. The string is in the form xxxxx.xxxxxxx.xxx or xxxx.xxxxx.xxx.xx.
> Does
> anyone have any idea how to validate this string.
> VB2005

What if it is smtp.servername.bc.ca or similar? You don't get those?
Author
30 Apr 2006 6:58 PM
Chris Chilvers
Show quote Hide quote
On Sun, 30 Apr 2006 18:41:53 GMT, "Homer J Simpson" <nob***@nowhere.com>
wrote:

>
>"Ben" <B**@discussions.microsoft.com> wrote in message
>news:6E18AFDE-5A22-4471-97C5-EF4274BFD47F@microsoft.com...
>> I am trying to validate a textbox in which the user enters the following -
>> "smtp.servername.com or .net or .org or .com.uk etc... and I cannot. I
>> have
>> tried. The string is in the form xxxxx.xxxxxxx.xxx or xxxx.xxxxx.xxx.xx.
>> Does
>> anyone have any idea how to validate this string.
>> VB2005
>
>What if it is smtp.servername.bc.ca or similar? You don't get those?
>
>

Or something like localhost or mymailcomuter.myinternaldomain
Author
30 Apr 2006 11:27 PM
Göran Andersson
Ben wrote:
> I am trying to validate a textbox in which the user enters the following -
> "smtp.servername.com or .net or .org or .com.uk etc... and I cannot. I have
> tried. The string is in the form xxxxx.xxxxxxx.xxx or xxxx.xxxxx.xxx.xx. Does
> anyone have any idea how to validate this string.
> VB2005
>

Use something like:

"(\w+\.){2,3}\w+"
Author
1 May 2006 12:10 AM
david
On 2006-04-30, Göran Andersson <gu***@guffa.com> wrote:
> Ben wrote:
>> I am trying to validate a textbox in which the user enters the following -
>> "smtp.servername.com or .net or .org or .com.uk etc... and I cannot. I have
>> tried. The string is in the form xxxxx.xxxxxxx.xxx or xxxx.xxxxx.xxx.xx. Does
>> anyone have any idea how to validate this string.
>> VB2005
>>
>
> Use something like:
>
> "(\w+\.){2,3}\w+"

Don't forget hyphen...

([-\w]+\.)+[-\w]+


OK, I spose that should really be...
(\w+([-\w]+)*\w\.)+(\w+([-\w]+)*\w)

That middle '+' should be a star if we want to match on the local
domain, though.

Beyond just ensuring it's a valid DNS hostname, I'm not sure if the OP
really has additional constraints or if the question is just poorly
worded, so I'm assuming we're just looking for well-formed names.
Author
1 May 2006 3:26 AM
Ben
Thanks to all of you. and Thanks for the website with the tutorials.
Thanks

Show quoteHide quote
"david" wrote:

> On 2006-04-30, Göran Andersson <gu***@guffa.com> wrote:
> > Ben wrote:
> >> I am trying to validate a textbox in which the user enters the following -
> >> "smtp.servername.com or .net or .org or .com.uk etc... and I cannot. I have
> >> tried. The string is in the form xxxxx.xxxxxxx.xxx or xxxx.xxxxx.xxx.xx. Does
> >> anyone have any idea how to validate this string.
> >> VB2005
> >>
> >
> > Use something like:
> >
> > "(\w+\.){2,3}\w+"
>
> Don't forget hyphen...
>
> ([-\w]+\.)+[-\w]+
>
>
> OK, I spose that should really be...
> (\w+([-\w]+)*\w\.)+(\w+([-\w]+)*\w)
>
> That middle '+' should be a star if we want to match on the local
> domain, though.
>
> Beyond just ensuring it's a valid DNS hostname, I'm not sure if the OP
> really has additional constraints or if the question is just poorly
> worded, so I'm assuming we're just looking for well-formed names.
>
>