I want to check the field with the British postal code. What regular expression can be used to validate this field ?. (([A-Z]{1,2}[0-9][0-9A-Z]{0,1})\ ([0-9][A-Z]{2}))|(GIR\ 0AA)$really valid because it has a GIR 0AA exception .
(([A-Z]{1,2}[0-9][0-9A-Z]{0,1})\ ([0-9][A-Z]{2}))|(GIR\ 0AA)$
So please help me write an expression without any exceptions.
If you mean a zip code, wikipedia has a verification section . One regular expression that it recommends:
((A[BL]|B[ABDHLNRST]?|C[ABFHMORTVW]|D[ADEGHLNTY]|E[HNX]?|F[KY]|G[LUY]?|H[ADGPRSUX]|I[GMPV]|JE|K[ATWY]|L[ADELNSU]?|M[EKL]?|N[EGNPRW]?|O[LX]|P[AEHLOR]|R[GHM]|S[AEGKLMNOPRSTY]?|T[ADFNQRSW]|UB|W[ADFNRSV]|YO|ZE)[1-9]?[0-9]|([E|N|NW|SE|SW|W]1|EC[1-4]|WC[12])[A-HJKMNPR-Y]|[SW|W]([1-9][0-9]|[2-9])|EC[1-9][0-9]) [0-9][ABD-HJLNP-UW-Z]{2}
, .
: GIR 0AA ( , ).
GIR 0AA
, , , , , GU78 2AB ( GU78 2AA, 2AB), GU77 2AB .
, , , . , , , :
(([A-Z]{1,2}[0-9]{1,2})\ ([0-9][A-Z]{2}))|(GIR\ 0AA)$
^([A-PR-UWYZ0-9][A-HK-Y0-9][AEHMNPRTVXY0-9]?[ABEHMNPRVWXY0-9]? {1,2}[0-9][ABD-HJLN-UW-Z]{2}|GIR 0AA)$
Source: https://habr.com/ru/post/1759266/More articles:Javascript / jQuery - How to find a memory leak in my large amount of code? - javascriptCan you create objects through the Property setter? - c #Подключение к SQL Server 2000 с помощью ASP-страницы с помощью VB? - sqlWhy does PHP / MySQL insert my Chinese characters differently? - phpIntegrating .Net Service with Microsoft Exchange - .netRegarding help file in JAVA - javaThe primary key is VARBINARY or BLOB or VARCHAR for the primary key UUID - databasebind two arguments - c ++How to upload a file to the server in the iPhone SDK? - iphoneformatNumber: how to add 2 decimal digits at the end of numbers? - javaAll Articles