JavaScript String Operations

Code:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
    <body>
        <script type="text/javascript">
            var wshShell = new ActiveXObject("WScript.Shell")
            var sComputerName = wshShell.ExpandEnvironmentStrings("%COMPUTERNAME%")
            var text_match = "GOVARDHAN"
           
            if(sComputerName.match(text_match))
            //if(sComputerName.match("govardhan"))
            {
                document.write("[" + sComputerName + "] String matched criteria: [" + text_match + "]");
            } else {
                document.write("String Match failed");
                //document.write("<br /><br />Would you like to try again?<br /><br />");
            }
        </script>
    </body>
</html>

 

 

Output:

image

Leave a Reply

Your email address will not be published. Required fields are marked *