MCPcopy Create free account
hub / github.com/ashvardanian/StringZilla / rstrip

Method rstrip

include/stringzilla/stringzilla.hpp:2513–2517  ·  view source on GitHub ↗

* @brief Python-like convenience function, dropping suffix formed of given characters. * @see Similar to `boost::algorithm::trim_right_if(str, is_any_of(set))`. */

Source from the content-addressed store, hash-verified

2511 * @see Similar to `boost::algorithm::trim_right_if(str, is_any_of(set))`.
2512 */
2513 string_slice rstrip(byteset set) const noexcept {
2514 set = set.inverted();
2515 auto new_end = (pointer)sz_rfind_byteset(start_, length_, &set.raw());
2516 return new_end ? string_slice {start_, static_cast<size_type>(new_end - start_ + 1)} : string_slice();
2517 }
2518
2519 /**
2520 * @brief Python-like convenience function, dropping both the prefix & the suffix formed of given characters.

Callers 3

test_unit_stripFunction · 0.80
test_searchFunction · 0.80
basic_stringClass · 0.80

Calls 3

rawMethod · 0.80
sz_rfind_bytesetFunction · 0.70
invertedMethod · 0.45

Tested by 2

test_unit_stripFunction · 0.64
test_searchFunction · 0.64