// =========================================================================== // Copyright 2018 Autodesk, Inc. All rights reserved. // // Use of this software is subject to the terms of the Autodesk license // agreement provided at the time of installation or download, or which // otherwise accompanies this software in either electronic or hard copy form. // =========================================================================== // // // Creation Date: 20 February 2001 // // // // // // // strip( string $str ) // // // string : Stripped string // // // Removes the white space from the start and end of a string // // // string $str String to remove whitespace from. // // // strip " hi "; // // global proc string strip( string $str ) { string $result = $str; string $startWS = `match "^[ \t\n\r]*" $result`; // If the result of the match is identical to the argument then that // means the argument was made up entirely of whitespace characters and // there is no need to continue. // if ($startWS == $str) return ""; if ( size( $startWS ) > 0 ) { $result = substring( $result, size( $startWS ) + 1, size( $result ) ); } string $endWS = `match "[ \t\n\r]*$" $result`; if ( size( $endWS ) > 0 ) { $result = substring( $result, 1, size( $result ) - size( $endWS ) ); } return $result; }