#include <MsgBoxConstants.au3> ; to declare the Constants of MsgBox
Local $sRegex = "(?m)^([^.]+)\_([^.]+)\_([^.]+)\_([^.]+)\_([^.]+)\.fastq$"
Local $sString = "A10_S65_L001_R1_001.fastq" & @CRLF & _
"A8_S49_L001_R2_001.fastq" & @CRLF & _
"B7_S42_L001_R1_001.fastq" & @CRLF & _
"C5_S27_L001_R2_001.fastq" & @CRLF & _
"F4_S22_L001_R1_001.fastq" & @CRLF & _
"G2_S7_L001_R2_001.fastq" & @CRLF & _
"H1_S165_L001_R1_001.fastq" & @CRLF & _
"A10_S65_L001_R2_001.fastq" & @CRLF & _
"A9_S57_L001_R1_001.fastq" & @CRLF & _
"B7_S42_L001_R2_001.fastq" & @CRLF & _
"C6_S35_L001_R1_001.fastq" & @CRLF & _
"F4_S22_L001_R2_001.fastq" & @CRLF & _
"G3_S15_L001_R1_001.fastq" & @CRLF & _
"H1_S165_L001_R2_001.fastq"
Local $sSubst = "$1_$4.fastq"
Local $sResult = StringRegExpReplace($sString, $sRegex, $sSubst)
MsgBox($MB_SYSTEMMODAL, "Result", $sResult)
Please keep in mind that these code samples are automatically generated and are not guaranteed to work. If you find any syntax errors, feel free to submit a bug report. For a full regex reference for AutoIt, please visit: https://www.autoitscript.com/autoit3/docs/functions/StringRegExp.htm