I am using python to pattern match a string multiple times in a string. Problem:
string = 'The value = 1 The value = 2 The value = 3'
I want to grep only value but my output should be like:
['value = 1 value = 2 value = 3']
I am doing like this:
pattern = re.compile('[value = (\d+)]*')
values = pattern.search(string)
values.group(0)
Output:
''
i.e NULL (no match)
Please help me give the right regular expression to grep the required output.
=equals signs and the numbers in your input example, but your regular expression expects a space there. The output example is a single string in a list, did you mean to make that a list of 3 strings instead?*after yourbracket?string.replace('The ', '')works in this case ;)