Derive targetPattern automatically from sourcePattern

Less repetition, less memory use

Change-Id: I5795cb400aea770ea13a83f52ab7aac8babfb130