I think this will work but it would be interesting to know if this is performant at the scale of large fastq files. Regular expressions can exhibit big variations in performance, different patterns with identical effects can perform at very different speeds.
I think tools like say cutadapt and trimmomatic could be also used used separately for each adapter. Mothur also has an adaptor splitting and filtering command. And there are some dedicated tools for this (although lately since casava performs the job as well these tools have fallen off the radar).
Doesn't having the barcodes in the ID line also mean that the data has been already demultiplexed and the barcode information is not actually present in the data. When the Casava pipeline (that produced this data is run) you have the choice of inputting the number of mismatches.
The reads are multiplexed. I will edit my post to make my problem a little bit more clear.
If you give some details about your experiment, it would be easy to guess whether you have demultiplexed data or not. Usually, if its illumina data, the casava pipeline would have been run on your data. Confirm with your sequencing facility.
You can demultiplex FASTQ files while allowing mismatches in the barcodes with the tool TagDust 2, but by design it will not let you control the exact number of mismatches. (This is why I post this as a comment rather than as an answer). You can find a benchmark comparing it with other tools in its publication.