質問

I currently have the following validation expression for one of my asp.net controls, which ensures the user has entered, what we consider to be a valid UK postcode:

ValidationExpression="^\s*([A-Z]{1,2}[0-9R][0-9A-Z]?\s*[0-9][ABD-HJLNP-UW-Z]{2})\s*$"

This works fine if the user enters their postcode using uppercase, but I'd like it to ignore case and am not sure how to incorporate that into the above expression?

役に立ちましたか?

解決 2

The only simple solution is to put lowercase letters everywhere, i.e.: [0-9A-Za-z]

Other solutions are not always reliable.

他のヒント

I'd like it to ignore case

Activate the ignore case flag by adding this notation to your regex: i.

Your regex would like this one below:

ValidationExpression="/^\s*([A-Z]{1,2}[0-9R][0-9A-Z]?\s*[0-9][ABD-HJLNP-UW-Z]{2})\s*$/i"
ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top