in reply to Second Time Replace Regex
xdg had some valid questions, but barring additional info, here's a one-liner (see perlrun) solution:
Tested against this data:perl -i -0777 -pe 's/(\bAAAA )(QQQQ)(PPPP)( BBBB\b.*?\bCCCC XXXX )\2\3 +\b/$1$2$3$4$2/sg' /tmp/f
blah stuff AAAA QQQQPPPP BBBB stuff more stuff blah and CCCC XXXX QQQQPPPP and more stuff. blah stuff AAAA QQQQPPPP BBBB stuff more stuff blah and CCCC XXXX QQQQPPPP and more stuff.
|
---|
In Section
Seekers of Perl Wisdom