i have to read a line in which i looking for pattern like
width:40
height :50
left : 60
right: 70
following found the required pattern
line = "width:40"
match = re.search(r'width\s*:\s*\d+', line)
in above code i have hard-coded the regex pattern for width
i have stored all four variables in array key_word = ['width', 'height', 'left', 'right']
i want to search for pattern for all these variable like
for key in key_word:
match = re.search(key, line)
the problem is how can i make this key a raw string which will be a pattern like
r'width\s*:\s*\d+'
r'height\s*:\s*\d+'
r'left\s*:\s*\d+'
r'right\s*:\s*\d+'