extractTextBetweenBrackets function

Extract text between brackets.