Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Regex expression python

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

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>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
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading