Reynan
Reynan

Reputation: 261

how to allow characters, space and dot in regular expression?

ValidationExpression="^[a-zA-Z ]+$"

this is my current regular expression but it does not accept .(dot). I need to use it for names. like "Reynante A. Capco"

Upvotes: 1

Views: 12667

Answers (3)

muthupandian c
muthupandian c

Reputation: 1

Validation for must contain a number, a character and a dot. Sometimes it must include a space.

For example:

version1.1.1-----valid
            version 1.1.1---valid
              v1.1.----------not valid(not end with dot)
             .v1.1--------not valid(not start with dot)
               v1----valid
               version 12.1.1--------valid

It must contain character and number dot and space are necessary if its dot not start with dot and not end with dot

Upvotes: 0

d-v-lop-r
d-v-lop-r

Reputation: 66

The following expression gets all

  • characters (a-zA-Z)
  • whitespaces (\s) and
  • dots (\.)

between the string beginning (^) and end ($):

The '@' is necessary to quote the backslashes inside the string.

ValidationExpression=@"^[a-zA-Z\s\.]+$"

Upvotes: 2

Companjo
Companjo

Reputation: 1792

This should work:

/[a-zA-Z]|\d|\s|\.*/
  • Any letter a-z
  • Any digit 0-9
  • Any whitespace
  • Any dots

Upvotes: 1

Related Questions