function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion

Parsing Text to Numeric

i have a text field that i'm trying to convert to numeric.. it is a window size field that includes height and width...




window:  1/2 X 1 5/8

  convert to:  

height:     .5



i'm not really a coder, and i'm trying to use the .split method,  which works to divide the height and width, but once divided, i may have a whole number with no fraction, a whole number with a fraction or a fraction only.... i guess i could use split again, but not sure if this is the best way....


any help would be appreciated!


Split the Strings again by '/' and then use decimal devide this way-


String s='1/2 X 15/8';
String []str=s.split('X');
String []First=str[0].split('/');
String []Second=str[1].split('/');


Then use divide function -