I have a piece of text with lots of the words and number in it.
E.g. Sports Tops £54.50 Sports Shorts £15.00
Product Code: 012345 098765 054637 073547
Sports Sock £10.75 Sports Shoes £70.00
Product Code: 099947 088873 033556 035267
How do I extract all the codes starting with 0?
RegEx should help. For more info on Regex have a look here:
Regex help tutorial MEGAPOST – Making your first Regex post, Reusable Regex Patterns, Regex Troubleshooting, Sample Workflow and more
have a look on folllowing patterns:
(?<=Product Code: )(0\d+\ ?)+
getting the different blocks:
In addition to regex, another option would be to split the string by space, then use the string.startswith() method to identify all strings starting with “0”