on 2016 Jul 11 11:04 PM
Hi All,
I tried to write a a rule for UK postcode validation by using Match Pattern .when I test it giving right answers.
but this match pattern passing just first half postcode (AA9) also pass.
when I bind it to the postcode column it passing all the patterns except Just Numbers(12345,123456,7896-----fail) in that field.
it gives score 9.99.
Did anyone came across this problem,
please help me out or please can anyone share if they wrote the rule for this already.
Regards
Kumarr
Request clarification before answering.
Try this...
BEGIN
IF(
( match_pattern($Name, 'X9 9XX')) OR
( match_pattern($Name, 'X99 9XX')) OR
( match_pattern($Name, 'XX9 9XX')) OR
.............
)
Return True;
Else
Return False;
END
System takes any characters in place of X and any number in place of 9.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Adrian Thanks for the good suggestion with example.I tried the same with regular expression.
showing sample
(match_regex($POSTCODE, '[A-Z][0-9]{2} [0-9]{1}[A-Z]{2}', NULL)
match_regex($POSTCODE, '[A-Z]{2}[0-9] [0-9]{1}[A-Z]{2}', NULL)
match_regex($POSTCODE, '[A-Z][0-9][A-Z] [0-9]{1}[A-Z]{2}', NULL))
And Thanks for the link also.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Kumarr,
I'm not sure what the acceptable formats of a UK post code are. However, you may want to look at the REGEX rather than match pattern rule. With that you can specify numbers and if appropriate letters of allowable characters and length of the post code.
regards
Adrian
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Assume by '9' you mean any number rather than always a 9. Did you try multiple regex statements with OR statements?
match_regex($post_code, '[A-Z]{1}[0-9]{1}\s[0-9]{1}[A-Z]{2}', NULL) OR
match_regex($post_code, '[A-Z]{1}[0-9]{2}\s[0-9]{1}[A-Z]{2}', NULL) OR
match_regex($post_code, '[A-Z]{2}[0-9]{1}\s[0-9]{1}[A-Z]{2}', NULL) OR ... etc
Or look here:
http://stackoverflow.com/questions/164979/uk-postcode-regex-comprehensive
This has a reference to the UK Government Standard.
| User | Count |
|---|---|
| 12 | |
| 9 | |
| 6 | |
| 4 | |
| 4 | |
| 4 | |
| 3 | |
| 3 | |
| 2 | |
| 2 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.