match¶
- group turbo_strings_match
Functions
-
constexpr bool str_contains(std::string_view haystack, std::string_view needle) noexcept¶
Returns whether a given string
haystackcontains the substringneedle.Example:
std::string_view input("abc"); EXPECT_TRUE(turbo::str_contains(input, "b"));
- Parameters:
haystack – The string to search in.
needle – The substring to search for.
- Returns:
true if the substring is found, false otherwise.
-
bool str_ignore_case_contains(std::string_view haystack, std::string_view needle) noexcept¶
Returns whether a given string
haystackcontains the substringneedleignore case.Example:
std::string_view input("abc"); EXPECT_TRUE(turbo::str_ignore_case_contains(input, "B"));
- Parameters:
haystack – The string to search in.
needle – The substring to search for.
- Returns:
true if the substring is found, false otherwise.
-
constexpr bool str_ignore_case_contains(std::string_view haystack, char needle) noexcept¶
Returns whether a given string
haystackcontains the substringneedleignore case.Example:
std::string_view input("abc"); EXPECT_TRUE(turbo::str_ignore_case_contains(input, 'B'));
Note
This function is constexpr if and only if the compiler supports.
- Parameters:
haystack – The string to search in.
needle – The substring to search for.
- Returns:
true if the substring is found, false otherwise.
-
constexpr bool starts_with(std::string_view text, std::string_view prefix) noexcept¶
Returns whether a given string
textbegins withprefix.Example:
std::string_view input("abc"); EXPECT_TRUE(turbo::starts_with(input, "a"));
Note
This function is constexpr if and only if the compiler supports.
- Parameters:
text – The string to search in.
prefix – The substring to search for.
- Returns:
true if the substring is found, false otherwise.
-
constexpr bool ends_with(std::string_view text, std::string_view suffix) noexcept¶
Returns whether a given string
textends withsuffix.Example:
std::string_view input("abc"); EXPECT_TRUE(turbo::ends_with(input, "c"));
- Parameters:
text – The string to search in.
suffix – The substring to search for.
- Returns:
true if the substring is found, false otherwise.
-
constexpr bool str_equals_ignore_case(const std::string_view &piece1, const std::string_view &piece2) noexcept¶
Returns whether given ASCII strings
piece1andpiece2are equal, ignoring case in the comparison.Example:
std::string_view input("abc"); EXPECT_TRUE(turbo::str_equals_ignore_case(input, "ABC"));
Note
This function is constexpr if and only if the compiler supports.
- Parameters:
piece1 – The first string to compare.
piece2 – The second string to compare.
- Returns:
true if the strings are equal, false otherwise.
-
constexpr bool str_equals_ignore_case(const char *first, const char *last, std::string_view str) noexcept¶
Returns whether given ASCII strings
firstandlastare equal, ignoring case in the comparison.Example:
std::string_view input("abc"); EXPECT_TRUE(turbo::str_equals_ignore_case(input.data(), input.end(), "ABC"));
Note
This function is constexpr if and only if the compiler supports.
- Parameters:
first – The first string to compare.
last – The last string to compare.
str – The substring to search for.
- Returns:
true if the substring is found, false otherwise.
-
constexpr bool starts_with_ignore_case(std::string_view text, std::string_view prefix) noexcept¶
Returns whether a given ASCII string
textstarts withprefix, ignoring case in the comparison.Example:
std::string_view input("abc"); EXPECT_TRUE(turbo::starts_with_ignore_case(input, "A"));
- Parameters:
text – The string to search in.
prefix – The substring to search for.
- Returns:
true if the substring is found, false otherwise.
-
constexpr bool ends_with_ignore_case(std::string_view text, std::string_view suffix) noexcept¶
Returns whether a given ASCII string
textends withsuffix, ignoring case in the comparison.Example:
std::string_view input("abc"); EXPECT_TRUE(turbo::ends_with_ignore_case(input, "C"));
- Parameters:
text – The string to search in.
suffix – The substring to search for.
- Returns:
true if the substring is found, false otherwise.
-
constexpr bool str_contains(std::string_view haystack, std::string_view needle) noexcept¶