pub fn is_sarcasm(input: &str) -> IsSarcasmExpand description
Determines if input is SaRcAsM and what the case of the first letter is.
All non-alphanumeric characters will be ignored in the input. As a result, the SaRcAsM pattern only has to hold within groups of alphanumeric characters. This means the starting letter of any “secondary” alphanumeric groups can be any case.
While the encoder is well defined in the capitalization throughout the whole string, the decoder needs to be able to deal with many possible styles of writing SaRcAsM text.
§Edge Cases
AbC DeFandAbC dEf-> SaRcAsM.Ab-CdandAb-cD-> SaRcAsM.A-> SaRcAsM.!!-> Too Short (no alphanumeric characters to judge).A!AandA!a-> SaRcAsM.
§Arguments
input- String slice to check for SaRcAsM.
§Return
IsSarcasm dictating if the input text was SaRcAsM.
§Examples
ⓘ
assert_matches!(is_sarcasm("AbC"), IsSarcasm::Yes(StartingCase::Uppercase));
assert_matches!(is_sarcasm("aBc"), IsSarcasm::Yes(StartingCase::Lowercase));
assert_matches!(is_sarcasm("Abc"), IsSarcasm::No);
assert_matches!(is_sarcasm("aBC"), IsSarcasm::No);
assert_matches!(is_sarcasm(""), IsSarcasm::TooShort);
assert_matches!(is_sarcasm("!!"), IsSarcasm::TooShort);