This sounds good for using regular expressions. In particular, regular expressions allow you to match a range of characters - [AZ{}] will match any character that is either an uppercase letter, { , or } .
EDIT based on new requirements - you want to match something that starts with the literal { , and then has at least one character in the AZ range, and then close } . Which gives a regex:
{[AZ]+}
This way you can match the entire regex:
val input = "{VARIABLE}" return input.test(/{[AZ]+}/) // returns true "{VARiABLE}".test(/{[AZ]+}/) // returns false "{ VARIABLE}".test(/{[AZ]+}/) // returns false "".test(/{[AZ]+}/) // returns false - open bracket didn't match "{}".test(/{[AZ]+}/) // returns false - AZ part didn't match
source share