I tried building the regex in regex101. In regex101 the code is working but when I am trying to run that cod in Python it is not working. Can anyone please help me in correcting the mistake? The code is
> for file in glob.glob('*TxtMsg*'):
> with open(file) as f:
> names = []
> contents = f.read()
> if 'Nbsequence::findtest System.SerialNumber=' in contents:
> print(re.match(r'(\w*)(?: Active\) Nbsequence::findtest System.SerialNumber=)(\d+)', contents))
Code Identifies required files from a location Read it one by one to identify it has required info or not If it has then it check for regex patter to extract required info.
Sample data is
succeeded to get serial number, Module = ABC Active, SerialNumber = 8212____________
[00007841][2022-07-04 16:48:30.581][Info][P00800 SunnyDay][T18304]: DayModule::FetchSerialNumber, fetching via web service..., SlotId = 1, IpAddress = 156.185.1.21, Port = 3990
[00007842][2022-07-04 16:48:30.597][Info][P00800 SunnyDay][T13844]: (ABC Active) Nbsequence::findtest (System.SerialNumber)
[00007843][2022-07-04 16:48:30.597][Info][P00800 SunnyDay][T13844]: (ABC Active) Nbsequence::findtest System.SerialNumber=8212____________
[00007844][2022-07-04 16:48:30.606][Info][P00800 SunnyDay][T13844]: (PQR Active) Nbsequence::findtest (System.SerialNumber)
[00007845][2022-07-04 16:48:30.608][Info][P00800 SunnyDay][T13844]: (PDIM Active) Nbsequence::findtest (System.SerialNumber)
[00007846][2022-07-04 16:48:30.613][Info][P00800 SunnyDay][T13844]: (PQR Active) Nbsequence::findtest System.SerialNumber=8198____________
[00007847][2022-07-04 16:48:30.615][Info][P00800 SunnyDay][T13844]: (WPC Activ
Appreciate your help in this
Result will be (Underlined in Blue) ABC: 8212, PQR: 8198



