When you are escaping Regular Expression in RegExp constructor, you need to escape like this
var matchtxt = new RegExp('\\w+\\.ms\\.com', "i");
\w+, translates to w+. So you need to escape \ with \\, which makes \ as part of the regular expression.
var labhost = '0';
var podmaster_node = "evhlab65.ms.com";
var matchtxt = new RegExp('\\w+\\.ms\\.com', "i");
if (podmaster_node.match(matchtxt)) {
labhost = '1';
}
document.getElementById("result").innerHTML = labhost;
<div id="result" />
Note: The better way to do this would be to use Regular Expression literal, like this
var matchtxt = /\w+\.ms\.com/i;