Expand description
§str Utils
This crate provides some traits to extend [u8], str and Cow<str>.
§Examples
use str_utils::*;
assert_eq!(true, "foobar".starts_with_ignore_ascii_case("FoO"));
assert_eq!(Some(1), "photo.jpg".ends_with_ignore_ascii_case_multiple(&[".png", ".jpg", ".gif"]));
assert_eq!(true, "http".eq_ignore_ascii_case_with_uppercase("HTTP")); // faster than `eq_ignore_ascii_case`
assert_eq!(true, "foobar".starts_with_ignore_ascii_case("FoO"));
assert_eq!("here is a ZERO_WIDTH_SPACE -> ".len() - 3, "here is a ZERO_WIDTH_SPACE -> ".remove_all_invisible_characters().len());
assert_eq!(r"foo\% b\_r", r"foo% b_r".escape_ascii_characters(b'\\', b"%_"));
assert!(!"AaBb\u{0130}Zz".is_lowercased());
assert!(!"AaBbZz".is_ascii_lowercased());
assert!(!"aabbßzz".is_uppercased());
assert!(!"aabbzz".is_ascii_uppercased());
assert_eq!("aabbi\u{0307}zz", "AaBb\u{0130}Zz".to_lowercase_cow());
assert_eq!("aabb\u{0130}zz", "AaBb\u{0130}Zz".to_ascii_lowercase_cow());
assert_eq!("AABBSSZZ", "aabbßzz".to_uppercase_cow());
assert_eq!("AABBßZZ", "aabbßzz".to_ascii_uppercase_cow());
assert_eq!("Line 1 Line 2 Line 2 Line 3 Line 4 Line 5", "Line 1\r\nLine 2\r\nLine 2\rLine 3\nLine 4\nLine 5".replace_newlines_with_space());
assert_eq!("abc", Cow::from(" abc ").trim_cow()); // the `trim_cow` family of methods can be used on a `Cow<str>` to allow fluent method chaining.§No Std
Disable the default features to compile this crate without std.
[dependencies.str-utils]
version = "*"
default-features = falseTraits§
- Ends
With Ignore Ascii Case - To extend
[u8]andstrto haveends_with_ignore_ascii_case,ends_with_ignore_ascii_case_with_lowercaseandends_with_ignore_ascii_case_with_uppercasemethods. - Ends
With Ignore Ascii Case Multiple - To extend
[u8]andstrto haveends_with_ignore_ascii_case_multiple,ends_with_ignore_ascii_case_with_lowercase_multipleandends_with_ignore_ascii_case_with_uppercase_multiplemethods. - Ends
With Ignore Case alloc - To extend
strto have aends_with_ignore_casemethod. - Ends
With Multiple - To extend
[u8]andstrto have aends_with_multiplemethod. - EqIgnore
Ascii Case - To extend
[u8]andstrto haveeq_ignore_ascii_case_with_lowercaseandeq_ignore_ascii_case_with_uppercasemethods. - EqIgnore
Ascii Case Multiple - To extend
[u8]andstrto haveeq_ignore_ascii_case_multiple,eq_ignore_ascii_case_with_lowercase_multipleandeq_ignore_ascii_case_with_uppercase_multiplemethods. - EqIgnore
Case unicase - To extend
strto have aeq_ignore_casemethod. - EqMultiple
- To extend
[u8]andstrto have aeq_multiplemethod. - Escape
Characters alloc - To extend
strandCow<str>to haveescape_charactersandescape_ascii_charactersmethod. - IsAscii
Lowercased - To extend
[u8]andstrto haveis_ascii_lowercasedmethod. - IsAscii
Uppercased - To extend
[u8]andstrto haveis_ascii_uppercasedmethod. - IsLowercased
- To extend
strto haveis_lowercasedmethod. - IsUppercased
- To extend
strto haveis_uppercasedmethod. - Remove
Invisible Characters alloc - To extend
strandCow<str>to haveremove_all_invisible_charactersmethod. - Replace
Newlines With Space alloc - To extend
strandCow<str>to havereplace_newlines_with_spacemethod. - Starts
With Ignore Ascii Case - To extend
[u8]andstrto havestarts_with_ignore_ascii_case,starts_with_ignore_ascii_case_with_lowercaseandstarts_with_ignore_ascii_case_with_uppercasemethods. - Starts
With Ignore Ascii Case Multiple - To extend
[u8]andstrto havestarts_with_ignore_ascii_case_multiple,starts_with_ignore_ascii_case_with_lowercase_multipleandstarts_with_ignore_ascii_case_with_uppercase_multiplemethods. - Starts
With Ignore Case alloc - To extend
strto have astarts_with_ignore_casemethod. - Starts
With Multiple - To extend
[u8]andstrto have astarts_with_multiplemethod. - ToLowercase
alloc - To extend
strandCow<str>to haveto_lowercase_cowandto_ascii_lowercase_cowmethods. - ToUppercase
alloc - To extend
strandCow<str>to haveto_uppercase_cowandto_ascii_uppercase_cowmethods. - Trim
alloc - To extend
Cow<str>to havetrim_cow,trim_start_cow,trim_end_cow,trim_ascii_cow,trim_ascii_start_cow,trim_ascii_end_cowmethods.