I'm trying to get a regex to work with rename; I've tried the approach of similar answered questions here but couldn't get the results I wanted.

The files are named as such:

    SR1_S90_L001_R1_001.fastq.gz 
    SR1_S90_L001_R2_001.fastq.gz
    Rinc_S96_L001_R1_001.fastq.gz 
    Rinc_S96_L001_R2_001.fastq.gz

And I would like to retain only the information prior to the first underscore and the _R1_ or _R2_ tags, like this:

    SR1_R1_.fastq.gz
    SR1_R2_.fastq.gz
    Rinc_R1_.fastq.gz 
    Rinc_R2_.fastq.gz

Thanks in advance!
Quick python solution. 

    #!/usr/bin/env python
    import os, glob
    
    for file in glob.glob("*.fastq.gz"):
    	# test with print statement
    	print file, '\t', file.split('_')[0] + '_' + file.split('_')[3] +  '_.fastq.gz'
    	# uncomment to rename
    	# os.rename(file, file.split('_')[0] + '_' + file.split('_')[3] +  '_.fastq.gz')
        
Save as `rename_fastq.py`; run as `python rename_fastq.py` in the directory containing fastq.gz files.

Not sure why you want to keep `'_'` after the R*