The following,though redundant, works perfectly :
'leap of, faith'.replace(/([^ \t]+)/g,"$1");
and prints "leap of, faith", but in the following :
'leap of, faith'.replace(/([^ \t]+)/g,RegExp.$1);
it prints "faith faith faith"
As a result when I wish to capitalize each word's first character like:
'leap of, faith'.replace(/([^ \t]+)/g,RegExp.$1.capitalize());
it doesn't work. Neither does,
'leap of, faith'.replace(/([^ \t]+)/g,"$1".capitalize);
because it probably capitalizes "$1" before substituting the group's value.
I want to do this in a single line using prototype's capitalize() method