I am a novice in python and have an issue using regex(). I have a parent directory and a subdirectory in it.
I'm using the regex(r'(.*/)?(.+/)(.+)\.bam')
to match the file with prefix '.bam' present in the subdirectory. A function utilizes the regex(), performs some task and gives the output and i need the output to be written to the parent directory.
Here is the total function which i am trying to do.
func(task,regex(r'(.*/)?(.+/)(.+)\.bam'),r'\1\3.output')
'.output' is the suffix to be added to the output and it shows the error "error: unmatched group". Could anyone help to fix this? or provide an elegant way to do this?

regexfunction? Your regex compiles just fine.