RSTools 3.1.0
Versatile C++20 utility library
Loading...
Searching...
No Matches
Replace.hpp
Go to the documentation of this file.
1#pragma once
2
3#include <cstddef>
4#include <string>
5#include <string_view>
6
7namespace RST::String {
8
12
14 std::size_t replaceAll(std::string& str, std::string_view from, std::string_view to);
15
17 [[nodiscard]] std::string replaceAllCopy(std::string_view str, std::string_view from, std::string_view to);
18
20 bool replaceFirst(std::string& str, std::string_view from, std::string_view to);
22}
String helpers: case, trimming, splitting, joining, replacing, parsing and hashing.
Definition Char.hpp:3
bool replaceFirst(std::string &str, std::string_view from, std::string_view to)
Replaces the first from in str with to; returns false if there is none.
std::size_t replaceAll(std::string &str, std::string_view from, std::string_view to)
Replaces every from in str with to and returns the number of replacements.
std::string replaceAllCopy(std::string_view str, std::string_view from, std::string_view to)
Returns a copy of str with every from replaced by to.
std::optional< T > parseNumber(std::string_view text, int base=10) noexcept
Parses text as a number, or returns std::nullopt if it is not entirely one.
Definition Convert.hpp:23