Connecting Tech Pros Worldwide Forums | Help | Site Map

Regular expression question with .NET

Andrew Gaskell
Guest
 
Posts: n/a
#1: Jul 19 '05
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
Guest
 
Posts: n/a
#2: Jul 19 '05

re: Regular expression question with .NET


agaskelluk@yahoo.com (Andrew Gaskell) wrote in
news:63c811db.0309040631.56201437@posting.google.c om:
[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)

Andrew Gaskell
Guest
 
Posts: n/a
#3: Jul 19 '05

re: Regular expression question with .NET


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

Regards
Andrew

Michael Lang <ml@nospam.com> wrote in message news:<Xns93EC7B7A0E3Flang1474icqmailcom@207.46.248 .16>...[color=blue]
> agaskelluk@yahoo.com (Andrew Gaskell) wrote in
> news:63c811db.0309040631.56201437@posting.google.c om:
>[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]
Closed Thread