문제

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