fork download
  1. import re
  2. a_string = "Anakinra 100 mg, gentechnologisch hergestellt aus E. coli."
  3. pattern = 'Anakinra'
  4. print ( [f"{x}{y}" for x,y in re.findall(rf"(?:{pattern})\s*(\d+(?:[.,]\d+)*)\s*(g|mg|)", a_string)] )
  5.  
Success #stdin #stdout 0.03s 9612KB
stdin
Standard input is empty
stdout
['100mg']