Regular expression question with .NET

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

    #1

    Regular expression question with .NET

    Dear all

    I'm having problems generating a regular expression in .NET, having
    just started using regular expressions.

    I am trying to validate a user's full name. So far I have:

    [\D]* as the regular expression to prevent the user entering digits.

    However I also want to disallow the following characters which have no
    place in a name: !"£$%^&*()_-+=@:;{[}]~#>.<,?/|\`¬

    Can someone please tell me what I need to do to add to my current
    regular expression above in order to do this?

    Thanks very much
    Andrew
  • Michael Lang

    #2
    Re: Regular expression question with .NET

    agaskelluk@yaho o.com (Andrew Gaskell) wrote in
    news:63c811db.0 309040631.56201 437@posting.goo gle.com:
    [color=blue]
    > Dear all
    >
    > I'm having problems generating a regular expression in .NET, having
    > just started using regular expressions.
    >
    > I am trying to validate a user's full name. So far I have:
    >
    > [\D]* as the regular expression to prevent the user entering digits.
    >
    > However I also want to disallow the following characters which have no
    > place in a name: !"£$%^&*()_-+=@:;{[}]~#>.<,?/|\`¬
    >
    > Can someone please tell me what I need to do to add to my current
    > regular expression above in order to do this?
    >
    > Thanks very much
    > Andrew
    >[/color]

    Why not just specify what the name CAN contain. It is much easier...

    [a-zA-Z]*

    --
    Michael Lang, MCSD
    See my .NET open source projects
    http://sourceforge.net/projects/colcodegen/ (simple generic code generator)
    http://sourceforge.net/projects/dbobjecter (database app code generator)
    http://sourceforge.net/projects/genadonet ("generic" ADO.NET)

    Comment

    • Andrew Gaskell

      #3
      Re: Regular expression question with .NET

      Michael
      thanks very much! I think I was making it too difficult!

      Regards
      Andrew

      Michael Lang <ml@nospam.co m> wrote in message news:<Xns93EC7B 7A0E3Flang1474i cqmailcom@207.4 6.248.16>...[color=blue]
      > agaskelluk@yaho o.com (Andrew Gaskell) wrote in
      > news:63c811db.0 309040631.56201 437@posting.goo gle.com:
      >[color=green]
      > > Dear all
      > >
      > > I'm having problems generating a regular expression in .NET, having
      > > just started using regular expressions.
      > >
      > > I am trying to validate a user's full name. So far I have:
      > >
      > > [\D]* as the regular expression to prevent the user entering digits.
      > >
      > > However I also want to disallow the following characters which have no
      > > place in a name: !"£$%^&*()_-+=@:;{[}]~#>.<,?/|\`¬
      > >
      > > Can someone please tell me what I need to do to add to my current
      > > regular expression above in order to do this?
      > >
      > > Thanks very much
      > > Andrew
      > >[/color]
      >
      > Why not just specify what the name CAN contain. It is much easier...
      >
      > [a-zA-Z]*[/color]

      Comment

      Working...