0
$\begingroup$

I have the following data :

Node : WATER-7609-WR1 

IP Address : 172.20.150.81

Severity : 5 - Critical

ServerSerial : 50505223

SNSupportGroup : UC-WAN

Node Location : CO 160 WATER 8 FL RCV

Event Details : Unknown Not Link Down or Up trap on Serial Channel:  Unknown Severity: 4
NOTE:Configuration Item is not found in CMDB. Please update Incident with related Configuration Item

I am interested in all text after "Event Details :", I have used the the following function :

def eventdetails(text): 
   match =re.search(r'Event Details :[^.]*',text) 
   return match

print(eventdetails(dfnetcool_inc["Description"][3])) 

output: <_sre.SRE_Match object; span=(159, 292), match='Event Details : Unknown Not Link Down or Up trap > 

--> Am not getting all of the text after Event Details. Perhaps there is an EOL charecter - how do I get remainder of the text, request your help, TIA!

$\endgroup$
  • $\begingroup$ Could you help us by indicating which part of the message you are interested in? $\endgroup$ – El Burro Apr 1 '19 at 14:46
  • $\begingroup$ I am interested in all text after "Event Details :", I have used the the following function : def eventdetails(text): match =re.search(r'Event Details :[^.]*',text) return match print(eventdetails(dfnetcool_inc["Description"][3])) output: <_sre.SRE_Match object; span=(159, 292), match='Event Details : Unknown Not Link Down or Up trap > --> Am not getting all of the text. $\endgroup$ – Vivek Rmk Apr 1 '19 at 15:54
  • $\begingroup$ solved : I used - match =re.findall(r'Event Details :[^*]+',flags= re.M, string= text) $\endgroup$ – Vivek Rmk Apr 1 '19 at 21:07
1
$\begingroup$

nice that you solved it. This would also work:

import re

def eventdetails(text): 
   match =re.search(r'Event Details :(.*)',text, flags=re.S) 
   return match

result = eventdetails(text)
print(result.group(0))
|improve this answer|||||
$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.