I have the following string
[1] weight | width | depth | 5.0 cm | 6.0 mm^2 | 10.12 cm^3
From that I need to extract the name, value and units from the above string like below
name = weight
value = 5.0
unit = cm
name = width
value = 6.0
unit = cm^2
name = depth
value = 10.12
unit = cm^3
I have the following regexes for each match cases. Individually each one is working as expected. But combining the regex is needed, so it will return the expected match cases. I tried just combining them all and also using |. But not worked. Here is the working regex for individual matches
For Name : (?<name>\b\w+(?:[\w]\w+)+\b)
For Value : (?<![\^])(?<value>[+-]?[0-9]+(?:\.[0-9]+)?)(?!\S)
For Unit : \b[0-9]+(?:\.[0-9]+)?[^\S\r\n]+(?<unit>[^0-9\s]\S*)(?:[^\S\r\n]+\||$)
Can anyone help me on this. Thanks