RegularExpression only letters in the Model

2

Using the following RegularExpression in Model:

[RegularExpression(@"^\d+$")]
public int ano_da_configuracao { get; set; }

I get the following result:

Itriedthefollowingwaytoacceptonlyletters:

[RegularExpression(@"/^[A-ZÁÀÂÃÉÈÍÏÓÔÕÖÚÇÑ ]+$/")]

Thinking you could achieve the same result, but it did not work.

How can I correct this expression to work as the first example?

    
asked by anonymous 11.02.2015 / 18:21

1 answer

2

The correct would look like this:

[RegularExpression(@"^[a-zA-Z]+$", ErrorMessage = "Use apenas caracteres alfabéticos.")]
public String MinhaString { get; set; }
    
12.02.2015 / 05:15