I have the following case. In a log there is multiple hashes that can be extracted with the following regex
\b[a-fA-F\d]{32}\b
In this example we have 3 hashes that will be matching with the previous regex, but I want to exclude the ones that the field is named 'link' and 'value'
u'closed_by': {u'link': u'https://test.test.com/api/now/table/sys_user/175f7cc0d7989d87bc43e322c42c8da8', u'value': u'175f7cc0d7989d87bc43e322c42c8da8'}, u'sensor_name': u'175f7cc0d7989d87bc43e322c42c8da8'
I tried the following regex but didn't work, should be matching the last hash 'sensor_name'
(\b[a-fA-F\d]{32}\b)((.?!'link':\s\S \')\,|(.?!'value':\s\S \')\},)
**Note: this is only an extract of the original log, the match should be to anything that is a hash except the fields 'link' and 'value' following to 'lin', could be multiple fields named 'value'
Can someone help me to know what I'm doing wrong, please?
CodePudding user response:
Use this pattern - any key words you want to avoid can be added to the lookbehind
(?<!link|value)': u'([\da-zA-Z]{32})