in reply to regexp and a perl function
s/a/substr($b,0,1)/e ; s/b/substr($b,1,1)/e ; [download]
(definition:) it evaluates the right hand side of s/// as an expression .
Enjoy, Mickey