void utStringUtils::replace( utString &in, const utString &from, const utString &to ) { if ( !from.empty() && from != to ) { // erase if ( to.empty() ) { size_t pos= 0; while ( pos != utString::npos ) { pos= in.find( from ); if ( pos != utString::npos ) in.erase( pos, from.size() ); } } else { size_t pos= 0; while ( pos != utString::npos ) { pos= in.find( from ); if ( pos != utString::npos ) { in.erase( pos, from.size() ); in.insert( pos, to ); } } } } }
void utStringUtils::split(utStringArray &rval, const utString &spl, const utString &expr ) { utString string= spl; rval.reserve( 32 ); for ( ;; ) { size_t pos= string.find_first_of( expr ); if ( pos != utString::npos ) { // chop first if ( pos == 0 ) pos= pos + 1; utString sub= string.substr( 0, pos ); if ( !sub.empty() && expr.find( sub ) == utString::npos ) rval.push_back( sub ); string.erase( 0, pos ); } else { if ( !string.empty() ) rval.push_back( string ); break; } } }