JSFiddle - React, Tailwind, and code Playground

by Rolf Friedrich

JavaScript

var regex = /[+-]?\d+(\.\d+)?/g;

var str = '[[&quot;if( {quantity} <= 14, 1.17647058823552 , if( {quantity} <= 29,0.924369747899159,0.75630252100840336))&quot;]]';
str = str.split('if');
console.log( str );
for( let i = 1; i < str.length; i++ ){
  var floats = str[i].match(regex).map(function(v) { return parseFloat(v); });
  console.log(floats.round(2));
  if( floats.length === 2){
                             console.log( 'jep')   ;
                            }
  
}