I have a series of text that contains mixed numbers (ie: a whole part and a fractional part). The problem is that the text is full of human-coded sloppiness:

  1. The whole part may or may not exist (ex: "10")
  2. The fractional part may or may not exist (ex: "1/3")
  3. The two parts may be separated by spaces and/or a hyphens (ex: "10 1/3", "10-1/3", "10 - 1/3").
  4. The fraction itself may or may not have spaces between the number and the slash (ex: "1 /3", "1/ 3", "1 / 3").
  5. There may be other text after the fraction that needs to be ignored

I need a regex that can parse these elements so that I can create a proper number out of this mess.

Edit
Report