Reputation: 68720
Text:
(18.8 x 25.7 x 1.8 cm)
10.787 x 8.031 x 1.339"
2.75 x 6.5 x 6.5 in
31 x 21.89 x 1.89 cm
(18.8 x 25.7 x 1.8 cm)
10.787 x 8.031 x 1.339"
2.75 x 6.5 x 6.5 in
31x21.89x1.89 mm
Expression:
/(\d*\.?\d+) x (\d*\.?\d+)(?: x (\d*\.?\d+))\s*(cms?|in|inch|inches|mms?)\b/ig
Currently matches some of the values from my test case, but i'd like it to:
Upvotes: 0
Views: 655
Reputation: 62636
This change will give you what you are looking for:
/^(?:[\(])?(\d*\.?\d+)\s*x\s*(\d*\.?\d+)\s*x\s*(\d*\.?\d+)\s*((?:cms?|in|inch|inches|mms?)\b|(?:[\"]))/igm
You can check here:
http://regexr.com/3eg8i
This is the breakdown:
^
(or beginning of line, using the /m modifier at the end)(
but don't catch it (?:[\(])
(\d*\.?\d+)
(int or float [with the dot])x
char, with (or without) space before and after `\sx\s - support multiple spaces here(?:cms?|in|inch|inches|mms?)\b
"
char |(?:[\"])
Upvotes: 3