9 Replies Latest reply on Oct 18, 2018 2:04 AM by Tim Guth

    RegEx: extract year OR age

    Tim Guth

      Hey Guys,

       

      I am currently facing regular expressions. I got a file like the following:

       

      long string field (yes, delimiter are not consistent, only for separating height and weight, but name, age/year, and body fat are sometimes delimited, sometimes not)

       

      name, age/year born, body fat%, height, weight

      James Smith 43 year old 18%, 180, 86
      Thomas Miller 1980, 11.2%, 191, 82
      Dean Thomas, 43 year old 13.1%, 174, 71

      (thanks Lei)

       

      I have multiple questions:

       

      1) I want to either extract the age (2 digits) or the year the person was born in. What would the code/regular expression for that be? I tried multiple but I am struggling to find the right code. Extraction should look like --> "43 year old" or "1980"

       

      2) What would the code for extracting the body fat be? The decimal place is indicated by a dot, some indications have a dot, some are a. absolute number. Extraction should look like --> "13.1%" or "18%"

       

      Thanks a lot for your help!

       

      Best

      Tim