0

I am having a string which is having repeating patterns but not sure how many they are. I want to grep these using regex

For example:

I am having following string

str = "var1 123 var2 234 key sdrfw3 current junk varn adads"
match = re.search("(\w*)\s*(\w*)", str)
print match.group(1), match.group(2)

Problem is I am not sure how many key values will come in this string but all will follow same pattern. How to grep key and value

Sumit
  • 1,953
  • 6
  • 32
  • 58

0 Answers0