-2

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.

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

I am using Jupyter Notebook

akashKP
  • 137
  • 9

1 Answers1

-2

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

Gedas Miksenas
  • 959
  • 7
  • 15