0

I need a regular expression that allows english alphabets and numbers and "-" and not allow every thing else. but recently I found out that my regular expression not stopping french language alphabets and numbers

My regular expression is as follow,

@"[^\w\d-]";

How can I change the above regular expression so only english alphabets, numbers and "-" can be allowed only?

fc123
  • 898
  • 3
  • 16
  • 40

1 Answers1

3

How can I change the above regular expression so only english alphabets, numbers and "-" can be allowed only?

@"^[A-Za-z0-9-]+$"

^ asserts that we are at the start. $ Asserts that we are at the end. + repeats the previous token one or more times.

Avinash Raj
  • 172,303
  • 28
  • 230
  • 274