This answer teaches me how to yank matches of regex group into one register. But I want to yank two into two different registers. I've tried the following but failed.
:%s/\(regex1\)\(regex2\)/\=setreg('a', submatch(1))\=setreg('b', submatch(2))/n
An error thrown out says invalid expression
. Then I modified it to be like this:
:%s/\(regex1\)\(regex2\)/\=setreg('a', submatch(1)) | \=setreg('b', submatch(2))/n
Then I get the error E493 backwards range given
.
Can I do what I want? If so, how should I correct this snippet?