Regular expression problem

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • dmalhotr2001@yahoo.com

    #1

    Regular expression problem

    Hi,

    I would like to know how to write regular expression in vb.net that
    would be valid for a piece of text that is only numbers, letters,
    dashes, and underscores that is allowed.

    Thanks

    :D
  • Spam Catcher

    #2
    Re: Regular expression problem

    dmalhotr2001@ya hoo.com wrote in news:449748e9-9059-46ed-bd89-934318d6e7f9
    @e6g2000prf.goo glegroups.com:
    Hi,
    >
    I would like to know how to write regular expression in vb.net that
    would be valid for a piece of text that is only numbers, letters,
    dashes, and underscores that is allowed.

    [A-Za-z0-9\_]*


    --
    spamhoneypot@ro gers.com (Do not e-mail)

    Comment

    • jamil@onepost.net

      #3
      Re: Regular expression problem

      On Tue, 18 Mar 2008 13:08:02 -0700 (PDT), dmalhotr2001@ya hoo.com
      wrote:
      >Hi,
      >
      >I would like to know how to write regular expression in vb.net that
      >would be valid for a piece of text that is only numbers, letters,
      >dashes, and underscores that is allowed.
      >
      >Thanks
      >
      >:D
      The following expression will do what you requested:

      ^(?:\w|-)+$

      This will match text containing numbers, letters, underscores and
      dashes. If any other characters exist in the string, it will not
      match.

      If you want partial matches in your string, remove the two anchors as
      follows:

      (?:\w|-)+

      To actually learn how I created that, there are a few books explaining
      regular expressions. I like Friedl's book Master Regular Expressions.

      Comment

      • rowe_newsgroups

        #4
        Re: Regular expression problem

        On Mar 18, 4:08 pm, dmalhotr2...@ya hoo.com wrote:
        Hi,
        >
        I would like to know how to write regular expression in vb.net that
        would be valid for a piece of text that is only numbers, letters,
        dashes, and underscores that is allowed.
        >
        Thanks
        >
        :D
        One extremely useful resource for composing regular expressions is
        Expresso. It's helps me out a ton whenever I have to use Regex.

        Check it out at:



        Thanks,

        Seth Rowe [MVP]

        Comment

        Working...