I'm trying to extract dimensions and units from text.
The data could look like anything:
53 inch x 45 inch
10 in by 5 in
53" W x 74" L x 15" H
53 inch W x 74 inch L x 15 inch H
There are posts which cover the first two cases but I was not able to understand how to deal with case 3 and 4 here.
This is what I tried for the basics from this but somehow it doesn't work:
import re
regex = r"(?<!\S)\d+(?:,\d+)?\s*(?:inch|in| in|\")* ?x ?\d+(?:,\d+)?(?: ?x ?\d+(?:,\d+)?)*\s*(?:inch| inch|in| in|\")*"
test_str = ("15 mm x 2 mm x 3")
result = re.findall(regex, test_str)
print(result)
Also, I just want to extract just these because I am using Quantulum for just extracting other numeric values but it fails in this case. So any guidance on how to merge the two things to function together would be very much appreciated.
Thank you for help