isBracketWrapped method
Checks if the string starts and ends with matching brackets.
e.g., (abc), [abc], {abc}, <abc>.
Implementation
bool isBracketWrapped() {
// A wrapped string must have at least 2 characters.
if (length < 2) return false;
// Check for each pair of matching brackets.
return (startsWith('(') && endsWith(')')) ||
(startsWith('[') && endsWith(']')) ||
(startsWith('{') && endsWith('}')) ||
(startsWith('<') && endsWith('>'));
}