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

Why this regex is not matching the text string?

I have a python code as follows:

import re
string=" S/O: fathersName,other details,some other details."`
fathersName=re.match(r":.*?,",string).group(0)

The regex match is supposed to match the fatherName part of the string, but I get a attributr error saying no mathces found

I even tried with re.match(':',string) and still I get 0 matches.

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

I think it is somehow related to : symbol, but I’m not sure.

I am using Jupyter Notebook

>Solution :

fathersName=re.search(r"S/O:\s*(.*?),",string).group(1)

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