MCPcopy Create free account
hub / github.com/SpartanJ/eepp / trim

Method trim

src/eepp/core/string.cpp:1020–1025  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1018}
1019
1020std::string String::trim( const std::string& str, char character ) {
1021 std::string::size_type pos1 = str.find_first_not_of( character );
1022 std::string::size_type pos2 = str.find_last_not_of( character );
1023 return str.substr( pos1 == std::string::npos ? 0 : pos1,
1024 pos2 == std::string::npos ? str.length() - 1 : pos2 - pos1 + 1 );
1025}
1026
1027std::string_view String::lTrim( const std::string_view& str, char character ) {
1028 std::string::size_type pos1 = str.find_first_not_of( character );

Calls 4

find_first_not_ofMethod · 0.80
find_last_not_ofMethod · 0.80
substrMethod · 0.80
lengthMethod · 0.45

Tested by

no test coverage detected