Merging two strings
CJam, 9 bytes
leul.e>el
Test it here.
Explanation
Makes use of the fact that '.' < upper case letters < lower case letters
. This way, when taking the element-wise maximum between two strings, any letter overrides a .
, but we can make a letter from the second input override a letter from the first if we upper case the first. Confusing? Here's one of the test cases as an example:
ab.ab.
b.b.b.
Convert first to upper case:
AB.AB.
b.b.b.
Take the element-wise maximum:
bBbAb.
Convert back to lower case:
bbbab.
And here is how the code does that:
l e# Read first line.
eu e# Convert to upper case.
l e# Read second line.
.e> e# Take element-wise maximum. If the lengths are different, the additional elements
e# from the longer list are just appended.
el e# Convert back to lower case.
Jelly, 5 bytes
Œu»Œl
Input via command-line arguments.
Try it online!
Explanation
This is a direct port of my CJam answer (see that for an explanation why this works):
Œu # Convert first argument to upper case.
» # Element-wise maximum between both strings.
Œl # Convert result back to lower case.
Javascript ES6, 52 55 chars
(a,b)=>b.replace(/\./g,(m,i)=>a[i]||m)+a.slice(b.length)
Test
f=(a,b)=>b.replace(/\./g,(m,i)=>a[i]||m)+a.slice(b.length)
;`
a....b ..c... a.c..b
aaaaaa bbbbbb bbbbbb
ab.ab. b.b.b. bbbab.
a.......b c c.......b
c a....b a....b
`.split('\n').filter(Boolean).map(s=>s.split(/\s+/)).every(a=>f(a[0],a[1])==a[2])