scripting - String splitting python -
i trying parse file , split line in python. can parse file , load list. i trying take each line , split parenthesis, 'datediff(varchar(30),timestamp(3),timestamp(3))' reverse(text) checkcluster(int,int,int,int,int) declaredown(int) i trying extract parameters in side function so: ['varchar(30),timestamp(3),timestamp(3)','text','int,int,int,int,int','int'] however result getting is: ['varchar(30', 'text', 'int,int,int,int,int', 'int'] i believe because of bracket in varchar. there way split first occurrence , last occurrence of parenthesis? is there way split first occurrence , last occurrence of parenthesis? yes, use partition , rpartition . >>> s = 'datediff(varchar(30),timestamp(3),timestamp(3))' >>> s.partition("(") ('datediff', '(', 'varchar(30),timestamp(3),timestamp(3))') >>> s.partition("(")[2]