0

Working with python I'm using this regex code:

r",\s((?<!\w)(?:(?=[MDCLXVI])M{0,3}(?:C[MD]|D?C{0,3})(?:X[CL]|L?X{0,3})(?:I[XV]|V?I{0,3})|\d+)(?!\w))\(([0-9]+)\),|,\s[0-9]+,"

To find the following kind of pattern in a text and get the character before and inside the parenthesis:

, 13(21),
, XVII(23),

But sometimes the parenthesis are missing and I have this:

, 13,
, XVII,

Is there a way to edit my regex code to also catch this case?

Diana Mele
  • 47
  • 4

0 Answers0