Regular Expression

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Ben

    #1

    Regular Expression

    I am trying to validate a textbox in which the user enters the following -
    "smtp.servernam e.com or .net or .org or .com.uk etc... and I cannot. I have
    tried. The string is in the form xxxxx.xxxxxxx.x xx or xxxx.xxxxx.xxx. xx. Does
    anyone have any idea how to validate this string.
    VB2005

  • pvdg42

    #2
    Re: Regular Expression


    "Ben" <Ben@discussion s.microsoft.com > wrote in message
    news:6E18AFDE-5A22-4471-97C5-EF4274BFD47F@mi crosoft.com...[color=blue]
    >I am trying to validate a textbox in which the user enters the following -
    > "smtp.servernam e.com or .net or .org or .com.uk etc... and I cannot. I
    > have
    > tried. The string is in the form xxxxx.xxxxxxx.x xx or xxxx.xxxxx.xxx. xx.
    > Does
    > anyone have any idea how to validate this string.
    > VB2005
    >[/color]
    You might consider a tutorial such as these...






    Comment

    • Homer J Simpson

      #3
      Re: Regular Expression


      "Ben" <Ben@discussion s.microsoft.com > wrote in message
      news:6E18AFDE-5A22-4471-97C5-EF4274BFD47F@mi crosoft.com...[color=blue]
      > I am trying to validate a textbox in which the user enters the following -
      > "smtp.servernam e.com or .net or .org or .com.uk etc... and I cannot. I
      > have
      > tried. The string is in the form xxxxx.xxxxxxx.x xx or xxxx.xxxxx.xxx. xx.
      > Does
      > anyone have any idea how to validate this string.
      > VB2005[/color]

      What if it is smtp.servername .bc.ca or similar? You don't get those?



      Comment

      • Chris Chilvers

        #4
        Re: Regular Expression

        On Sun, 30 Apr 2006 18:41:53 GMT, "Homer J Simpson" <nobody@nowhere .com>
        wrote:
        [color=blue]
        >
        >"Ben" <Ben@discussion s.microsoft.com > wrote in message
        >news:6E18AFD E-5A22-4471-97C5-EF4274BFD47F@mi crosoft.com...[color=green]
        >> I am trying to validate a textbox in which the user enters the following -
        >> "smtp.servernam e.com or .net or .org or .com.uk etc... and I cannot. I
        >> have
        >> tried. The string is in the form xxxxx.xxxxxxx.x xx or xxxx.xxxxx.xxx. xx.
        >> Does
        >> anyone have any idea how to validate this string.
        >> VB2005[/color]
        >
        >What if it is smtp.servername .bc.ca or similar? You don't get those?
        >
        >[/color]

        Or something like localhost or mymailcomuter.m yinternaldomain

        Comment

        • Göran Andersson

          #5
          Re: Regular Expression

          Ben wrote:[color=blue]
          > I am trying to validate a textbox in which the user enters the following -
          > "smtp.servernam e.com or .net or .org or .com.uk etc... and I cannot. I have
          > tried. The string is in the form xxxxx.xxxxxxx.x xx or xxxx.xxxxx.xxx. xx. Does
          > anyone have any idea how to validate this string.
          > VB2005
          >[/color]

          Use something like:

          "(\w+\.){2,3}\w +"

          Comment

          • david

            #6
            Re: Regular Expression

            On 2006-04-30, Göran Andersson <guffa@guffa.co m> wrote:[color=blue]
            > Ben wrote:[color=green]
            >> I am trying to validate a textbox in which the user enters the following -
            >> "smtp.servernam e.com or .net or .org or .com.uk etc... and I cannot. I have
            >> tried. The string is in the form xxxxx.xxxxxxx.x xx or xxxx.xxxxx.xxx. xx. Does
            >> anyone have any idea how to validate this string.
            >> VB2005
            >>[/color]
            >
            > Use something like:
            >
            > "(\w+\.){2,3}\w +"[/color]

            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.

            Comment

            • Ben

              #7
              Re: Regular Expression

              Thanks to all of you. and Thanks for the website with the tutorials.
              Thanks

              "david" wrote:
              [color=blue]
              > On 2006-04-30, Göran Andersson <guffa@guffa.co m> wrote:[color=green]
              > > Ben wrote:[color=darkred]
              > >> I am trying to validate a textbox in which the user enters the following -
              > >> "smtp.servernam e.com or .net or .org or .com.uk etc... and I cannot. I have
              > >> tried. The string is in the form xxxxx.xxxxxxx.x xx or xxxx.xxxxx.xxx. xx. Does
              > >> anyone have any idea how to validate this string.
              > >> VB2005
              > >>[/color]
              > >
              > > Use something like:
              > >
              > > "(\w+\.){2,3}\w +"[/color]
              >
              > 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.
              >
              >[/color]

              Comment

              Working...