I want pattern by regular expression match list it contains constant, variable and empty list [] such as [emy,X,[],W,yara] regex r("\\[+ [a-z]*||([A-Za-z]*||(\\[+\\] )+\\, +\\]");