// =========================================================================== // 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. // =========================================================================== // // // // // // string stringRemovePrefix(string $object, string $prefix ) // // // Return a new string whose contents is equivalent to $object without $prefix // // // string $object The input string. // // string $prefix The string to be removed from the beginning of $object. // // // string : A new string whose contents is equivalent to $object without $prefix. // // // // // // stringRemovePrefix( "a", "" ); // // ,Result:, a // // // size( stringRemovePrefix( "", "a" ) ); // // ,Result:, 0 // // // stringRemovePrefix( "aa", "a" ); // // ,Result:, a // // // stringRemovePrefix( "a", "___" ); // // ,Result:, a // // // stringRemovePrefix( "a", "abc" ); // // ,Result:, a // // // size( stringRemovePrefix( "a", "a" ) ); // // ,Result:, 0 // // // // global proc string stringRemovePrefix( string $object, string $prefix ) { int $m = size( $prefix ); if ( $m > 0 ) { int $n = size( $object ); if ( $n && substring( $object, 1, $m ) == $prefix ) $object = ( $m != $n ) ? substring( $object, $m+1, $n ) : "" ; } return $object; }