public static String cleanUnit ( String unit ) { if ( unit == null ) return null ; // These specific words become dimensionless if ( unit . equalsIgnoreCase ( "Proportion" ) || unit . equalsIgnoreCase ( "Numeric" ) ) unit = "" ; // So does '-' else if ( unit . equalsIgnoreCase ( "-" ) ) { unit = "" ; // Make sure degree(s) true gets concatenated with '_' } else if ( unit . startsWith ( "degree" ) && unit . endsWith ( "true" ) ) { unit = unit . replace ( ' ' , ' ' ) ; // And only do the rest of the conversion if it's not a "* table *" entry } else if ( ! unit . contains ( " table " ) ) { if ( unit . startsWith ( "/" ) ) unit = "1" + unit ; unit = unit . trim ( ) ; unit = StringUtil2 . remove ( unit , "**" ) ; StringBuilder sb = new StringBuilder ( unit ) ; StringUtil2 . remove ( sb , "^[]" ) ; StringUtil2 . replace ( sb , ' ' , "." ) ; StringUtil2 . replace ( sb , ' ' , "." ) ; unit = sb . toString ( ) ; } return unit ; }
Clean up strings to be used for unit string