Take a look at this post at stackoverflow: http://stackoverflow.com/questions/164979/uk-postcode-regex-comprehensive It provides the official regex of the UK government. If you have problems checking this regex let us now so we can help you further.
Regards,
Ronald
[EDIT] Look here for the documentation here: https://world.mendix.com/display/refguide6/Regular+Expressions and the part about java here: http://www.regular-expressions.info/java.html You should excape the characters with a extra slash \.
Okay, thanks for the link, just to confirm, am I using IsMatch correctly with the below?
isMatch ($Patient/Postcode,'^(([gG][iI][rR] {0,}0[aA]{2})|((([a-pr-uwyzA-PR-UWYZ][a-hk-yA-HK-Y]?[0-9][0-9]?)|(([a-pr-uwyzA-PR-UWYZ][0-9][a-hjkstuwA-HJKSTUW])|([a-pr-uwyzA-PR-UWYZ][a-hk-yA-HK-Y][0-9][abehmnprv-yABEHMNPRV-Y]))) {0,}[0-9][abd-hjlnp-uw-zABD-HJLNP-UW-Z]{2}))$')
or should it be different to reject the characters such as such as ",!,£,$,%,^,&,*,(,) {,},<,>,?,\ ?
When I used the above, it seem to be accepting all the nonsensical characters, and I have also tried similar to below: isMatch($yourvariable, '^([0-9]+)$') it has not worked.
Hi all,
I have validated the below regular expression for UK post codes in Regular Expression testing sites, but when I use the same with isMatch, I get an error and the post code for e.g: OX1 1LF, does not seem to get accepted.
I am don't really know what I am not doing correctly here and would really appreciate your help.
Below is my regular expression with the isMatch for your reference:
isMatch ($Patient/Postcode,'[^a-zA-Z]{3}+[^0-9]{3,2}[ ^0-9]+[^a-zA-Z]{2,3}\$')
Please can someone help me? I need urgent help.
Best Regards Nimesh
Whatever you do, make sure you create a dedicated microflow for this, so you can call this everytime you validate a postcode, and do not end up having multiple copies of the regex scattered around your application.
We use the following:
isMatch($Postcode,'(GIR ?0AA)|((([A-Z-[QVX]][0-9][0-9]?)|(([A-Z-[QVX]][A-Z-[IJZ]][0-9][0-9]?)|(([A-Z-[QVX]][0-9][A-HJKSTUW])|([A-Z-[QVX]][A-Z-[IJZ]][0-9][ABEHMNPRVWXY])))) ?[0-9][A-Z-[CIKMOV]]{2})')
This looks a lot like the official UK government regex (I didn't even know there was such a thing), and works fine for us so far.
I would not worry too much about allowing whatever characters users will try to put in. In cases like this, you will never get it perfect anyway, and it is better to err on the side of allowing too much then allowing too little.