I have multiple strings which looks like this
product: green apples price: 2.0 country: france company: somecompany. Some strings might have fewer fields. For example some are missing company name or country etc. I am trying to extract values only and skip product,price,country,company. I tried to create multiple regexes, which starts from the left side of each string.
blah="product: green apples price: 2.0 country: france company: somecompany"
product_reg = re.compile(r'.*?\bproduct\b:(.*).*')
product_reg_strip = re.compile(r'(.*?)\s[a-z]:?')
product_full=re.findall(product_reg, blah)
prod=re.find(product_reg_strip, str(product_full))
print prod
price_reg = re.compile(r'.*?\bprice\b:(.*).*')
price_reg_strip = re.compile(r'(.*?)\s[a-z]:?')
price_full=re.findall(price_reg, blah)
price=re.find(price_reg_strip, str(price_full))
print price
But this is not working. What should i do to make this regex more sane?
green apples 2.0 france somecompany?