Quantcast
Channel: Reformat string containing uk postcode using regex - Stack Overflow
Browsing latest articles
Browse All 4 View Live

Answer by ShrapNull for Reformat string containing uk postcode using regex

I've used the excellent answer from @borodin above to create a UK postcode as-you-type formatter. Note, this does not validate the postcode, just formats it according to borodin's regex as the user...

View Article



Answer by Borodin for Reformat string containing uk postcode using regex

If you use the regular expression /^([A-Z]{1,2}\d{1,2}[A-Z]?)\s*(\d[A-Z]{2})$/ you can extract the two parts of the postcode and reassemble them with an intervening space.var list = ['N13LD',...

View Article

Answer by Alnitak for Reformat string containing uk postcode using regex

Put braces around the bits separated by the optional space:/^([A-Za-z]{1,2}[0-9A-Za-z]{1,2})[ ]?([0-9]{0,1}[A-Za-z]{2})$/However I think the regexp is wrong... The above regexp splits "N13LD" as "N13",...

View Article

Reformat string containing uk postcode using regex

How can I format a string using Javascript to match a regex?I am using UK postcodes which could match any of the followingN1 3LDEC1A 3ADGU34 8RRI have the following regex which validates a string...

View Article
Browsing latest articles
Browse All 4 View Live




Latest Images