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

Method strip

include/stringzilla/stringzilla.hpp:2523–2531  ·  view source on GitHub ↗

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

Source from the content-addressed store, hash-verified

2521 * @see Similar to `boost::algorithm::trim_if(str, is_any_of(set))`.
2522 */
2523 string_slice strip(byteset set) const noexcept {
2524 set = set.inverted();
2525 auto new_start = (pointer)sz_find_byteset(start_, length_, &set.raw());
2526 return new_start ? string_slice {new_start,
2527 static_cast<size_type>(
2528 sz_rfind_byteset(new_start, length_ - (new_start - start_), &set.raw()) -
2529 new_start + 1)}
2530 : string_slice();
2531 }
2532
2533#pragma endregion
2534#pragma endregion

Callers 10

_detect_targetFunction · 0.80
sz_target_nameFunction · 0.80
setup.pyFile · 0.80
test_unit_stripFunction · 0.80
test_searchFunction · 0.80
parse_case_folding_fileFunction · 0.80
get_normalization_propsFunction · 0.80

Calls 4

rawMethod · 0.80
sz_find_bytesetFunction · 0.70
sz_rfind_bytesetFunction · 0.70
invertedMethod · 0.45

Tested by 7

test_unit_stripFunction · 0.64
test_searchFunction · 0.64
parse_case_folding_fileFunction · 0.64
get_normalization_propsFunction · 0.64