pub fn alternate_case(input: &str) -> StringExpand description
Alternates between uppercase and lowercase for each alphabetic character.
Creates a predictable pattern starting with uppercase, then lowercase, and repeating for each letter. Non-alphabetic characters don’t affect the pattern. This is also known as “spongebob case” or “mocking case”.
§Use Cases
- Testing: Verify case-insensitive string comparisons
- Visual: Create distinctive formatting for emphasis or mockery
- Red Team: Test filter bypass with alternating patterns
§Examples
use redstr::alternate_case;
assert_eq!(alternate_case("hello"), "HeLlO");
assert_eq!(alternate_case("hello world"), "HeLlO wOrLd");
// Non-alphabetic characters are preserved but don't affect the pattern
assert_eq!(alternate_case("a1b2c3"), "A1b2C3");