/* There are a lot of ways to go wrong with regular expressions-
this method ignores any flags in the first expression,
and doesn't check for errors- It is safer to write your regular expressions whole,
or build them up from strings. */
function mergeRx(start, end){
start= String(start).substring(1);
end= String(end).substring(1);
var rx=/\/([igm]+)?$/,
flag= end.match(/[igm]+$/) || '';
start= start.replace(rx, '')+end.replace(rx, '');
return RegExp(start, flag);
}
var A=/[^a-zA-Z]/, B=/.+/;
mergeRx(A, B)
/* returned value: (RegExp)
/[^a-zA-Z].+/
*/