I am trying to get a regex that will return all profiles, some have spaces and I don’t want to ignore All Users, here is my attempt,
(Profile \s*:)(\s....)
Profile : Infinix S4
Profile : MTN_4G_10A6B1
Profile : Bruteforce
Profile : CMB FINCON
Al User Profile : MTN_4G_10A6B1 All User Profile : Infinix S4 All User
Profile: CMB GEEKS All User Profile: MTNHyNetflex 5.0Ghz All User
Profile: CLASSICMAN-SEYI 4387 All User Profile: Bruteforce All User
Profile: MD_CMB All User Profile: CMB EXCO All User Profile: CMB
FINCON All User Profile: MTN_4G_D3CC32 All User Profile: HUK-MIFI
All User Profile : MTN_4G_D3CCD7 All User Profile : NSHS_CMB All User
Profile: NSHS_SPOT All User Profile: Communications Dept All User
Profile: CPDCL_SERVER1 All User Profile: CMB-PH-RM All User Profile
: TP-Link_EDBA All User Profile: MERCY
>Solution :
import re
text = 'Al User Profile : MTN_4G_10A6B1 All User Profile : Infinix S4 All User Profile: CMB GEEKS All User Profile: MTNHyNetflex 5.0Ghz All User Profile: CLASSICMAN-SEYI 4387'
data = re.finditer(r'(Profile)\s*[:]\s*\w*', text, re.IGNORECASE)
for match in data:
print(match.group(0))
result:
Profile : MTN_4G_10A6B1
Profile : Infinix
Profile: CMB
Profile: MTNHyNetflex
Profile: CLASSICMAN