I am using re to split a string based on regular expression, but I would like to keep the delimiters in the output array.
To make it clear, for a set of delimiters and string input I want to split the input each time the delimiter is met, but instead of keeping all characters following and excluding the delimiter, I want all characters following and including the delimiter. For example if my input is "FFG1G2ZZ2", and my delimiters [F,G,Z], I want as an output: F F G1 G2 Z Z Z2
input_string = "FFG1G2ZZ2"
output_list = re.split("FGZ", input_string)
print(output_list)
out: ['','','1','2','','2']
print(desired_output)
out: ['F','F','G1','G2','Z','Z2']