HI Guys,
I am looking to Parse a long decimal number from a String using REGEX.
File attached below however, sample string looks like this
"<SpotWholesale xmlns="RateCompositionInfo"><Value>0.91409999999999991</Value><State>Defaulted</State><CalculationMethod xsi:nil="true"/></SpotWholesale>
The piece I want parsed is after first <Value> , the only number in the string. So I can identify this number easily in Regex however, parsing the full decimal number is troublesome. It is rounding the number and giving me a whole number
Not all instances will there be a "0" before the decimal point
I want the full number extracted - HELP !
Solved! Go to Solution.
Thats amazing Felipe thank you. I had used XML earlier in my workflow but didn't realise I could parse further.
I am trying to improve my REGEX understanding, any ideas how this could be solved in REGEX ? - Juts for my own curiosity
Yes, there are multiple ways. Here is one of them:
REGEX_Replace([Value], '(.*<Value>)(.*)(<\/Value>.*)', '$2')
Basically, it means that we have a first group (.*<Value>), that has a any character + <Value>
Then, we have a second group of any characters (the group that we want)
And there is a third group (<\/Value>.*) that has <\/Value> + any character
And we want the second group = '$2'
String
anything<Value> 0.91409999999999991 </Value>anything
group 1 | group 2 | group 3
Thanks for this comprehensive answer Felipe