Wednesday, October 10, 2012

Google Spreadsheet Extract Zip Code from Cell


I have an RSS feed inserting html, text and numbers all into one Column M.  
I need to extract the first two zip codes from this large cell.

The best way to identify the numbers is that there is always an exact phrase before each zip "Pick-up at: random city(length varies)", "random state(always two capital letters) 5digitzipcode" 
Example as follows "Pick-up at: MILSFORD, OH 45150<BR>"
There is always one space before the zipcode and always <BR> immediately behind the number.

The second 5 digit zipcode always has the statement "Deliver to: "random city(length varies)", "random state(always two capital letters)5 digit number"
Example as follows: "Deliver to: WAUSEONENASSA, TN 43582<BR>"
There are other sets of 5 digit numbers in the same cell but none will have the exact identifiers descried above.

I am more familiar with excel and had this working there but due to other excel limitations I have started using google docs and am excited to see all the new possibilities!!! 
Your help is greatly appreciated.


Try the following formula, it will extract 5 continuous numbers and it will work in both of your cases:
the above formula will extract from Cell M2

And the following Arrayformula will extract from Column M:

I hope the above solution will help you, and if you need more help then please do comment below on this blog itself, I will try to help you out.

I also take up private or confidential projects:

If this blog post was helpful to you, and if you think you want to help me too and make my this blog survive then please donate here: 



  1. Hi thank you for your reply. The result is only showing as 00000. remember there are many strings of numbers in the cell, some are 1 or 2 digits and some are up to 9 digits. I only need the 5 digit zip codes immediately following the statements in my examples.

  2. +tjennnins, I posted this on the thread to see if it works on your data:

    =ArrayFormula(REGEXEXTRACT(M2;{"Pick-up at: [A-Z]+, [A-Z]{2} ([0-9]{5})\n","Deliver to: [A-Z]+, [A-Z]{2} ([0-9]{5})\n"}))